Home >Backend Development >PHP Tutorial >PHP implements the checkdnsrr function of the window platform, windowcheckdnsrr_PHP tutorial

PHP implements the checkdnsrr function of the window platform, windowcheckdnsrr_PHP tutorial

WBOY
WBOYOriginal
2016-07-13 09:52:23867browse

php implements the checkdnsrr function of the window platform. windowcheckdnsrr

PHP’s own checkdnsrr function is only valid on the linux platform. If you are used to using it and it cannot be used on the window platform, it will cause trouble for compatibility.

So I wrote a checkdnsrr simulation function for use in the window platform environment.

if (!function_exists('checkdnsrr ')) {
  function checkdnsrr($host, $type) {
    if(!empty($host) && !empty($type)) {
      @exec('nslookup -type=' . escapeshellarg($type) . ' ' . escapeshellarg($host), $output);
      foreach ($output as $k => $line) {
        if(eregi('^' . $host, $line)) {
          return true;
        }
      }
    }
    return false;
  }
}

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/1008018.htmlTechArticlephp implements the checkdnsrr function of the window platform. windowcheckdnsrr PHP's own checkdnsrr function is only valid on the Linux platform. If you are used to using it and it cannot be used on the window platform, it will cause trouble for compatibility...
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