Home >Backend Development >PHP Tutorial >Detailed explanation of the usage of PHP function checkdnsrr (Windows platform usage), detailed explanation of checkdnsrr_PHP tutorial

Detailed explanation of the usage of PHP function checkdnsrr (Windows platform usage), detailed explanation of checkdnsrr_PHP tutorial

WBOY
WBOYOriginal
2016-07-12 08:56:02890browse

Detailed explanation of the usage of PHP function checkdnsrr (Windows platform usage), detailed explanation of checkdnsrr

This article describes the usage of PHP function checkdnsrr with examples. Share it with everyone for your reference, the details are as follows:

This is what it says on php.net:

(PHP 4, PHP 5)

checkdnsrr — Check DNS records corresponding to a given Internet host name or IP address

Translation: checkdnsrr -- Check whether a given host name (domain name) or IP address has a DNS record, which is actually to check whether it exists.

Note: This function is now available on Windows platforms.

Note: This function is not supported on Windows platform

I tried it, and sure enough, it said there is no such function.

The following is a hack method, so that when we develop on Windows, we can also 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 let me introduce the parameters:

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

We won’t talk about the first parameter, it is the domain name or ip

The second parameter is the analysis type, respectively:

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)
The NS record is a record that specifies the domain name server and specifies which DNS should resolve the domain name.
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                                   Same as above
SRV record It is a type of resource record supported in the DNS server database. It is generally used when setting up Microsoft's Active Directory.
TXT record Text information
ANY record Any record, all data types

This function is often used by us to detect whether the email actually exists!

Readers who are interested in more PHP-related content can check out the special topics of this site: "Summary of PHP office document operation skills (including word, excel, access, ppt)", "Summary of PHP date and time usage", "php-oriented "Introduction Tutorial on Object Programming", "Summary of PHP String Usage", "Introduction Tutorial on PHP MySQL Database Operation" and "Summary of Common PHP Database Operation Skills"

I hope this article will be helpful to everyone in PHP programming.

Articles you may be interested in:

  • PHP implements the checkdnsrr function of the window platform
  • A brief analysis of PHP programs to prevent ddos, dns, and cluster server attacks from solutions
  • Briefly talk about the strlen function in PHP
  • php’s powerful time conversion function strtotime
  • PHP function timeout processing method
  • Detailed explanation of PHP closure function
  • Several common encryption functions of PHP
  • A summary of common functions used by PHP to execute linux commands
  • A summary of several practical custom functions of PHP
  • Use PHP scripts to use the md5 function under Linux Methods to encrypt strings
  • Methods to support PHP’s iconv() function on Linux systems
  • Instructions for using common functions of PHP to execute Linux system commands

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/1113743.htmlTechArticleDetailed explanation of the usage of PHP function checkdnsrr (Windows platform usage), detailed explanation of checkdnsrr This article describes the usage of PHP function checkdnsrr. Share it with everyone for your reference, the details are as follows: On php.net...
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn