What are some common challenges or pitfalls when implementing a domain-check feature in PHP?

One common challenge when implementing a domain-check feature in PHP is handling errors or exceptions that may occur during the domain lookup process. To address this, it is important to properly handle potential errors and exceptions to ensure the robustness of the feature.

try {
    $domain = 'example.com';
    $ip = gethostbyname($domain);
    if ($ip !== $domain) {
        echo "Domain $domain resolves to IP address: $ip";
    } else {
        echo "Domain $domain does not resolve to an IP address";
    }
} catch (Exception $e) {
    echo "Error occurred: " . $e->getMessage();
}