Check for Existence of DNS Records - checkdnsrr()

PHP How To

The Domain Name System (DNS) is what allows you to use domain names (e.g., example.com) in place of the corresponding IP address, such as 192.0.34.166. The domain names and their complementary IP addresses are stored on domain name servers, which are interspersed across the globe.

Typically, a domain has several types of records associated to it, one mapping the IP address to the domain, another for directing e-mail, and another for a domain name alias.

The checkdnsrr() function checks for the existence of DNS records. DNS records are checked based on the supplied host value and optional DNS resource record type, returning TRUE if any records are located and FALSE otherwise.

For example,

$recordexists = checkdnsrr("example.com", "ANY");
if ($recordexists)
{
echo "The domain name exists!";
}
else
{
echo "The domain name does not appear to exist!";
}

 You can also use this function to verify the existence of a domain of a supplied mail address.