This article is an example of how to query whois information in PHP. Share to everyone for your reference. Specifically as follows:
Here, use PHP to query the list of Web sites for whois information
function Whois_query ($domain) {//fix the domain name: $domain = Strtolower (Trim ($domain));
$domain = preg_replace ('/^http:\/\//i ', ', ', $domain);
$domain = preg_replace ('/^www\./i ', ', ', $domain);
$domain = explode ('/', $domain);
$domain = Trim ($domain [0]);
Split the TLD from domain name $_domain = explode ('. ', $domain);
$lst = count ($_domain)-1;
$ext = $_domain[$lst]; Your find lists//like to Wikipedia:////Http://de.wikipedia.org/wiki/Whois//$serve
rs = Array ("Biz" => "whois.neulevel.biz", "com" => "whois.internic.net", "Us" => "whois.nic.us", "Coop" => "Whois.nic.coop", "info" => "Whois.nic.info", "name" => "Whois.nic.name", "net" => "who Is.internic.net "," gov "=>" whois.nic.gov "," edu "=>" whois.internic.net "," Mil "=>" rs.internic.net " , "int" => "whois.iana.org", "AC" => "Whois.nic.ac", "AE" => "whois.uaenic.ae", "at" => "Whois.ripe.net", "au" => "whois.aunic.net", "Be" => "whois.dns.be", "BG" => "Whois.ripe.net", "b R "=>", "whois.registro.br", "BZ" => "Whois.belizenic.bz", "Ca" => "whois.cira.ca", "CC" => "WHOIS.N" ic.cc "," ch "=>" whois.nic.ch "," CL "=>" whois.nic.cl "," cn "=>" whois.cnnic.net.cn "," CZ "=> "whois.nic.cz", "de" => "whois.nic.de", "fr" => "whois.nic.fr", "Hu" => "whois.nic.hu", "ie" => ; "whois.domainregistry.ie", "il" => "whois.isoc.org.il", "in" => "whois.ncst.ernet.in", "ir" => "whois . nic.ir "," MC "=>" Whois.ripe.net "," to "=>" whois.tonic.to "," TV "=>" whois.tv "," Ru "=>" Who Is.ripn.net "," org "=>" whois.pir.org "," Aero "=>" Whois.information.aero "," NL "=>" Whois.domain-reg "
Istry.nl ");
if (!isset ($servers [$ext])) {die (' error:no matching NIC server found! ');
} $nic _server = $servers [$ext]; $output = ''; Connect to whois server:if ($conn = Fsockopen ($nic _server)) {fputs ($conn, $domain.)
\ r \ n ");
while (!feof ($conn)) {$output. = fgets ($conn, 128);
} fclose ($conn); else {die (' error:could not connect to '. $nic _server. '!');
return $output;
}//Some example Queries:print whois_query (' jonasjohn.de ');
Print whois_query (' example.com ');
Print whois_query (' example.org ');
I hope this article will help you with your PHP programming.