-
-
/** - * Whois information query
- * by bbs.it-home.org
- */
- function ae_whois($query, $server)
- {
- define('AE_WHOIS_TIMEOUT', 15); // connection timeout
- global $ae_whois_errno, $ae_whois_errstr;
// connecting
- $f = fsockopen($server, 43, $ae_whois_errno, $ae_whois_errstr, AE_WHOIS_TIMEOUT);
- if (!$f)
- return false ; // connection failed
// sending query
- fwrite($f, $query."rn");
// receiving response
- $response = '';
- while (!feof($f))
- $response .= fgets($f, 1024);
// closing connection
- fclose($f); p>
return $response;
- }
- ?>
-
-
Copy code
The above code implements a whois query function, including two parameters $query (whois Query information), $server (domain name server).
This function returns the server's response information, or returns false if it fails.
The fsockopen error code and error message will be written to the global variables $ae_whois_errno and $ae_whois_errstr.
You can change the constant AE_WHOIS_TIMEOUT to set the query timeout.
Example, used to obtain the domain name server information of the domain name jbxue.com.
Code:
-
- //whois information query
- echo ae_whois('jbxue.com', 'whois.verisign-grs.com');
- ?>
Copy code
Articles you may be interested in:
PHP obtains several global variables of the domain name
Detailed explanation of how to implement dns domain name query in php (pictures and text)
php example code to get domain name from url
How to get the source domain name of the site with php
Discuss: How to obtain domain name and domain name IP address with PHP
An example of using php to obtain the domain name code in the URL
PHP regular matching to obtain the code of the domain name in the URL
PHP gets the code of the current website and domain name
php regular expression matching domain name in URL
PHP calls Wanwang interface to implement domain name query function
|