checkdnsrr
(PHP 4, PHP 5)
checkdnsrr — Check DNS records corresponding to a given Internet host name or IP address
Описание
Searches DNS for records of type type corresponding to host .
Список параметров
- host
-
host may either be the IP address in dotted-quad notation or the host name.
- type
-
type may be any one of: A, MX, NS, SOA, PTR, CNAME, AAAA, A6, SRV, NAPTR, TXT or ANY. The default is MX.
Возвращаемые значения
Returns TRUE if any records are found; returns FALSE if no records were found or if an error occurred.
Список изменений
Версия | Описание |
---|---|
5.2.4 | TXT type was added. |
5.0.0 | AAAA type was added. |
Примечания
Замечание: This function is not implemented on Windows platforms. Try the » PEAR class » Net_DNS.
Смотрите также
- dns_get_record()
- getmxrr()
- gethostbyaddr()
- gethostbyname()
- gethostbynamel()
- the named(8) manual page
- checkdnsrr
- closelog
- define_syslog_variables
- dns_check_record
- dns_get_mx
- dns_get_record
- fsockopen
- gethostbyaddr
- gethostbyname
- gethostbynamel
- gethostname
- getmxrr
- getprotobyname
- getprotobynumber
- getservbyname
- getservbyport
- header_register_callback
- header_remove
- header
- headers_list
- headers_sent
- http_response_code
- inet_ntop
- inet_pton
- ip2long
- long2ip
- openlog
- pfsockopen
- setcookie
- setrawcookie
- socket_get_status
- socket_set_blocking
- socket_set_timeout
- syslog
Коментарии
criffoh at gmail dot com is right. Before you check domain, you must convert to ascii with idn_to_ascii function:
http://us2.php.net/manual/en/function.idn-to-ascii.php .
var_dump(checkdnsrr('ñandu.cl', 'A')); // returns false
var_dump(checkdnsrr(idn_to_ascii('ñandu.cl'), 'A')); // return true
Important Warning:
You need to add a dot to the end of the host name to make a fully qualified domain name.
To see why, try executing the following pieces of code:
$d1="gmail.con";
$d2="gmail.con.";
$r1=checkdnsrr($d1, "MX");
$r2=checkdnsrr($d2, "MX");
var_dump($r1);
var_dump($r2);
You will see that without the dot it claims that the domain "gmail.con" is valid.
Note that if you time the "checkdnsrr()" calls you will also see it takes longer without the dot because it treats it as a relative domain and does several tries based on the host name it is running on.
NB: in case you're interested, being treated as a relative domain explains what is happening. If your host is "example.com" the relative domain will eventually resolve to "gmail.con.com." which can be looked up, hence it wrongly claims "gmail.con" exists
I always think you should state the blindingly obvious.
A function that contains checkdnsrr will return false without an internet connection.
So in a production environment you need an active internet connection to return a true result with a valid email address.