php 检测domain信息

可以获得任一网站的信息

 

<?
    function WhoIs($DomainName)
    {
       
        // Open a socket to geektools.com, one of the whois servers
        $Socket = fsockopen("www.geektools.com", 43, $ErrorNum, $ErrorStr) or die("$errno: $errstr");
        fputs($Socket, $DomainName."\n");
        // Receive data from the whois server and put into a string
        while(!feof($Socket))
        {
            $WhoIsString .= fgets($Socket, 2048);
        }
        // Close the stream and return the string
        fclose($Socket);
        return $WhoIsString;
    }
   
    // Sample use of the WhoIs service
    echo "Who Is Geekpedia.com?<br />";
    echo "<pre>".WhoIs("baidu.com")."</pre>";
?>
 

 

 

 

你可能感兴趣的:(PHP,socket)