PHP code example of niko9911 / phpwhois

1. Go to this page and download the library: Download niko9911/phpwhois library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

niko9911 / phpwhois example snippets


$whois = new \phpWhois\Whois('google.com');
try {
    $response = $whois->lookup();
} catch (Exception $e) {
    echo 'Error: '.$e->getMessage();
}

if (is_null($response)) {
    exit('Can\'t get information about this address');
}

$responseIana = $whois->getResponseIana(); // Response from whois.iana.org
                                           // It provides the whois server for TLD in `refer` and `whois` fields
$responseIanaWhois = $whois->getResponseIanaWhois(); // Response from whois server provided by IANA
$response = $whois->getResponse(); // Response from the whois server specified by library or by user.
                                   // Returned with $whois->lookup()
                                   // If no special whois server was set - this is a copy of `$whois->responseIanaWhois`

// Load composer framework
if (file_exists(__DIR__ . '/vendor/autoload.php')) {
    ois->lookup($query,false);
echo "<pre>";
print_r($result);
echo "</pre>";

$result = $whois->lookup($query);

use phpWhois\Whois;
$whois = new Whois();
$result = $whois->lookup('example.com');

$whois = new Whois();
$result = $whois->lookup('62.97.102.115');

$whois = new Whois();
$result = $whois->lookup('AS220');

use phpWhois\Whois;
$whois = new Whois();
$whois->useServer('uk','whois.ripe.net?-V{version},{ip} {query}');
$result = $whois->lookup('62.97.102.115');

use phpWhois\Whois;
$whois = new Whois();
$whois->useServer('uk','whois.isoc.org.il?-V{version},{ip} {query}');
$result = $whois->lookup('example.co.uk');

use phpWhois\Whois;
$whois = new Whois();
$whois->useServer('uk','whois.nic.uk:1043?{hname} {ip} {query}');
$result = $whois->lookup('example.co.uk');

use phpWhois\Whois;
$whois = new Whois();
$whois->useServer('au','whois-check.ausregistry.net.au');

use phpWhois\Whois;
$whois = new Whois();
$whois->useServer('be','whois.tucows.com');

use phpWhois\Whois;
$whois = new Whois();
$whois->useServer('ip','whois.apnic.net');

$whois->deepWhois = false;