Example
Check DNS records:
html
<?php
$domain="example.com";
if(checkdnsrr($domain,"MX")) {
echo
"Passed";
} else {
echo "Failed";
}
?>
Definition and Usage
The checkdnsrr() function checks DNS records for type corresponding to host.
We can use the checkdnsrr() function to check the DNS record to verify the existence of a domain name or not.
Syntax
text
checkdnsrr(host, type)
Parameter Values
| Parameter | Description |
|---|---|
| host | Required. Specifies an IP address or host name to check |
| type | Optional. Specifies the type. Can be one of the following: A MX (default) NS SOA PTR CNAME AAAA A6 SRV NAPTR TXT ANY |
Technical Details
| Return Value: | TRUE if any records are found, FALSE otherwise |
|---|---|
| PHP Version: | 4.0+ |
| PHP Changelog: | PHP 5.3: Now available on Windows platformsPHP 5.2.4: Added the TXT value of type |