PHP function CHECKDNSRR Usage (Windows platform usage) _php tips

Source: Internet
Author: User
Tags check dns records php database domain name server mail exchange mx record

This article illustrates the CHECKDNSRR usage of PHP functions. Share to everyone for your reference, specific as follows:

That's what it says on the php.net:

(PHP 4, PHP 5)

Checkdnsrr-check DNS Records corresponding to a given the Internet host name or IP address

CHECKDNSRR-Check whether it has a DNS record based on a given host name (domain name) or IP address, in fact, verify that it exists.

The Note:this function is now available on Windows platforms.

Note: This function is not supported on the Windows platform

I tried it, and sure enough, the hint didn't have this function.

Here's a hack approach, so that when we do development on windows, we can see the effect!

if (!function_exists (' CHECKDNSRR ')) {
  function checkdnsrr ($host, $type = ') {
    if (!empty ($host)) {
      $type = ( Empty ($type))? ' MX ': $type;
      EXEC (' nslookup-type= '. $type. " '. Escapeshellcmd ($host), $result);
      $it = new Arrayiterator ($result);
      foreach (New Regexiterator ($it, ' ~^ '. $host. ~ ', Regexiterator::get_match) as $result) {
        if ($result) {return
          true;
        }
    }} return false;
  }
}

Next I'll introduce the parameters:

BOOL CHECKDNSRR (String $host [, String $type = "MX"])

The first parameter we will not say, is the domain name or IP

The second parameter is the resolution type, respectively:

A (address) record is a record of IP addresses for the specified host name (or domain name).
MX record is the specified mail exchange record (default)
The NS record is a record of the specified domain name server, specifying which DNS the domain name will be parsed by.
SOA records are typically used in a secondary DNS server to specify who is the primary server.
The reverse parsing record of the PTR record from the IP point to the domain name
CNAME record alias record
AAAA record is a record pointing to IPv6
A6 Record ditto
The SRV record is the type of resource record that is supported in the DNS server's database and is typically applied to Microsoft's Active Directory settings.
TXT record text information
Any records, all data types

This function is often used by us to detect whether an email is real!

For more information on PHP-related content readers can view the site topics: "PHP operation Office Document tips summary (including word,excel,access,ppt)", "PHP date and Time usage summary", "PHP object-oriented Program Design Introductory Course", "PHP string (string) Summary of usage, Getting Started tutorial on Php+mysql database operations, and summary of common PHP database operations techniques

I hope this article will help you with the PHP program design.

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.