search
Homephp教程php手册php window平台模拟checkdnsrr函数检测email是否真实存在

在php的系统函数中有一个checkdnsrr函数,该函数的作用是根据一个给定的host name(域名)或者IP地址检查它是否有DNS记录,目的就是检验它是否真实存在。但是该函数仅可以在linux系统下使用,并不支持windows平台。下面是网上搜集到的一个hack的方法,实现在window平台上模拟checkdnsrr函数来检测一个email是否存在的功能!

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

接下来我来介绍一下该函数的参数:

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

第一个参数我们就不说了,就是域名或者ip

第二个参数是解析类型,分别有:

A (Address) 记录     是指定主机名(或域名)对应的IP地址记录。

MX 记录              是指定邮件交换记录(默认)

NS 记录              是指定域名服务器的记录,指定该域名由哪个DNS来进行解析。

SOA记录              一般在辅助的dns服务器里才用到,用来指定谁是主服务器。

PTR记录              从ip指向域名的反向解析记录

CNAME记录            别名记录

AAAA记录             是一个指向IPv6的记录

A6记录               同上

SRV记录              它是DNS服务器的数据库中支持的一种资源记录的类型,一般是为Microsoft的活动目录设置时的应用。

TXT记录              文本信息

ANY记录              任何记录,所有数据类型

您可能感兴趣的文章

  • php利用filter函数验证邮箱、url和ip地址的方法
  • php获取汉字拼音首字母的函数(真正可以使用的)
  • Sphinx在windows下安装使用[支持中文全文检索]
  • php判断函数,类,类方法是否存在
  • php 模拟get_headers函数
  • php获取目录所有文件并将结果保存到数组的程序
  • windows环境下mysql数据库的主从同步备份步骤
  • JS常用函数收集(去除空格,验证邮箱,日期,正整数等)
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

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

Dreamweaver Mac version

Dreamweaver Mac version

Visual web development tools

WebStorm Mac version

WebStorm Mac version

Useful JavaScript development tools

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment