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!