PHP window platform simulates the checkdnsrr function to detect whether the email actually exists_PHP tutorial

WBOY
Release: 2016-07-13 10:28:11
Original
1065 people have browsed it

There is a checkdnsrr function in the PHP system function. The function of this function is to check whether it has a DNS record based on a given host name (domain name) or IP address. The purpose is to verify whether it actually exists. However, this function can only be used under Linux systems and does not support Windows platforms. The following is a hack method collected on the Internet to simulate the checkdnsrr function on the window platform to detect whether an email exists!

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;
    }
}
Copy after login

Next, let me introduce the parameters of this function:

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)

NS record is a record that specifies the domain name server, specifying 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

AAAA record is a record pointing to IPv6

A6 record                                                                                                                                                                                                                                                                        

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 Method

php function to get the first letter of Chinese pinyin (really usable)

Sphinx is installed and used under windows [supports Chinese full-text search]

php judgment function, class , whether the class method exists
  • php simulates the get_headers function
  • php program to get all the files in the directory and save the results to an array
  • Master-slave synchronization backup of mysql database in windows environment Steps
  • Collection of common JS functions (remove spaces, verify email, date, positive integer, etc.)
  • http://www.bkjia.com/PHPjc/813353.html
  • www.bkjia.com
true

http: //www.bkjia.com/PHPjc/813353.html

There is a checkdnsrr function in the PHP system function. The function of this function is based on a given host name ( Domain name) or IP address to check whether it has a DNS record, the purpose is to check whether it...
Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!