How to query whois information in PHP _php tips

Source: Internet
Author: User
Tags explode php programming

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" =&gt ; "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.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.