This function returns the WhoIs string for the passed domain name (such as the domain-name owner and nameservers) by opening a socket to a WhoIs server.
More PHP Resources
Advertisement
- <?
- 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(“geekpedia.com”).“</pre>”;
- ?>