Just a little bit of information which might help you. You probably know this already (or wish you did) but the
explode function can have an optional third argument called
limit. This enables you to limit the number of array elements returned. To put that into something visual:
PHP Code:
<?php
$domain = 'salathe.co.uk';
// Normal way of using explode
$parts_normal = explode('.', $domain); // array('salathe', 'co', 'uk')
// Limit the number of elements
$parts_limit = explode('.', $domain, 2); // array('salathe', 'co.uk')
// You could also do
$extension = array_pop(explode('.', $domain, 2)); // $extension = 'co.uk'
// Show some output
header('Content-Type: text/plain');
var_dump($parts_normal, $parts_limit, $extension);
Another point that I'd like to raise is that your objects (classes) should only really be doing one thing. Personally, I think that you
Whois class should be dealing only with the whois information, not handling the output at all (the Whois::display() method).
If somewhere along the line you have 20 classes all with a
display() method within them, it'll be a nightmare trying to debug the output and even worse if later on you decide that you want to offer both HTML and another form of output (XML, PDF, whatever).