What is the purpose of the checkdnsrr function in PHP?

The checkdnsrr function in PHP is used to check if a specified domain has a specific record type in its DNS entries. This can be useful for verifying domain configurations or checking for the existence of certain records like MX records for email servers.

$domain = 'example.com';
$record_type = 'MX';

if(checkdnsrr($domain, $record_type)){
    echo "The domain $domain has $record_type records.";
} else {
    echo "The domain $domain does not have $record_type records.";
}