What are the limitations of relying on DNS resolution for determining domain availability in PHP?

Relying solely on DNS resolution for determining domain availability in PHP can be unreliable as it may not accurately reflect the actual availability of a domain. A better approach would be to use a WHOIS lookup to check domain availability, as it directly queries the domain registrar's database for the most up-to-date information.

function isDomainAvailable($domain){
    $whois = shell_exec("whois $domain");
    if(strpos($whois, 'No match for') !== false){
        return true; // Domain is available
    } else {
        return false; // Domain is not available
    }
}

$domain = "example.com";
if(isDomainAvailable($domain)){
    echo "Domain $domain is available";
} else {
    echo "Domain $domain is not available";
}