PHP function checkdnsrr usage (Windows platform usage)

Source: Internet
Author: User
Tags check dns records domain name server mail exchange mx record to domain
This article mainly introduces the usage of the PHP function checkdnsrr, analyzes and explains how to use the checkdnsrr function on the Windows platform, and describes the usage of the PHP function checkdnsrr by referring to the example in this article. We will share this with you for your reference. The details are as follows:

On php.net, we say this:

(PHP 4, PHP 5)

Checkdnsrr-Check DNS records corresponding to a given Internet host name or IP address

Checkdnsrr-check whether a DNS record exists based on a given host name or IP address.

Note: This function is now available on Windows platforms.

Note: This function is not supported on windows.

I tried it. sure enough, I was prompted not to use this function.

The following is an hack method. in this way, we can see the effect when developing on windows!

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 we will introduce the parameters:

Bool checkdnsrr (string $ host [, string $ type = "MX"])

The first parameter is the domain name or ip address.

The second parameter is the resolution type, which includes:

The A (Address) record is the IP Address record corresponding to the specified host name (or domain name.
MX record is the specified mail exchange record (default)
An NS record is a record of a domain name server. it specifies the DNS to which the domain name is resolved.
SOA records are generally used in secondary dns servers to specify who is the primary server.
PTR record reverse resolution record pointing from ip to domain name
CNAME record alias record
The AAAA record is a record pointing to IPv6.
A6 record is the same as above
The SRV record is a type of resource record supported by the database of the DNS server. it is generally used when setting the Active Directory of Microsoft.
TXT records text information
ANY records, all data types

This function is often used to check whether the email actually exists!

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.