Are there any best practices recommended for using checkdnsrr in PHP applications?

When using the checkdnsrr function in PHP applications to check the DNS records of a domain, it is recommended to handle any potential errors or exceptions that may occur during the process. One best practice is to wrap the checkdnsrr function call within a try-catch block to catch any exceptions thrown and handle them accordingly.

<?php
$domain = 'example.com';

try {
    if(checkdnsrr($domain, 'A')) {
        echo 'DNS record found for domain: ' . $domain;
    } else {
        echo 'No DNS record found for domain: ' . $domain;
    }
} catch (Exception $e) {
    echo 'An error occurred while checking DNS records: ' . $e->getMessage();
}
?>