Implementation code for PHP WHOIS client queries

Source: Internet
Author: User
Tags php regular expression domain name server
    1. /**

    2. * Whois information Enquiry
    3. * by bbs.it-home.org
    4. */
    5. function Ae_whois ($query, $server)
    6. {
    7. Define (' Ae_whois_timeout ', 15); Connection Timeout
    8. Global $ae _whois_errno, $ae _whois_errstr;

    9. Connecting

    10. $f = Fsockopen ($server, $ae _whois_errno, $ae _whois_errstr, ae_whois_timeout);
    11. if (! $f)
    12. return false; Connection failed

    13. Sending query

    14. Fwrite ($f, $query. " \ r \ n ");

    15. receving response

    16. $response = ";
    17. while (!feof ($f))
    18. $response. = Fgets ($f, 1024);

    19. Closing connection

    20. Fclose ($f);

    21. return $response;

    22. }
    23. ?>
Copy Code

The above code implements a WHOIS query function that includes two parameter $query (whois query information), $server (domain name server). The function returns the server's response information, and the failure returns false. Fsockopen error codes and error messages are written to the global variables $ae_whois_errno and $AE_WHOIS_ERRSTR. You can change the constant ae_whois_timeout to set the query time-out.

example, to get the domain name server information for the domain name jbxue.com. Code:

    1. Whois information Query
    2. echo Ae_whois (' jbxue.com ', ' whois.verisign-grs.com ');
    3. ?>
Copy CodeYou may be interested in the article: PHP get the domain name of several global variables PHP implementation of DNS domain name Query method detailed (graphic) php from the URL to get the instance code of the domain name of PHP to obtain the site of the route domain name method discussion: PHP get domain name and domain name IP address method PHP Gets the code of the domain name in the URL a sample PHP matches the code of the domain name in the URL php gets the current URL and the code of the domain name PHP regular expression matches the domain name in the URL PHP call million network interface implementation of the domain name query function
  • 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.