checkdnsrr函数如何在php中使用

2023-05-21,,

本篇文章为大家展示了checkdnsrr函数如何在php中使用,内容简明扼要并且容易理解,绝对能使你眼前一亮,通过这篇文章的详细介绍希望你能有所收获。

PHP的自带checkdnsrr函数只在linux平台有效。使用惯了在window平台不能使用的话给兼容性带来麻烦。

因此写了个checkdnsrr模拟函数在window平台环境使用。

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;
  }
}

上述内容就是checkdnsrr函数如何在php中使用,你们学到知识或技能了吗?如果还想学到更多技能或者丰富自己的知识储备,欢迎关注本站行业资讯频道。

《checkdnsrr函数如何在php中使用.doc》

下载本文的Word格式文档,以方便收藏与打印。