What potential issues should be considered when using gethostbyname() to get the IP address of a domain?
One potential issue when using gethostbyname() is that it may not work properly if the DNS resolver configuration on the server is incorrect or if the domain name does not exist. To solve this issue, you can check the return value of gethostbyname() for errors and handle them accordingly.
$domain = "example.com";
$ip = gethostbyname($domain);
if ($ip === $domain) {
echo "Error resolving domain name.";
} else {
echo "IP address for $domain is: $ip";
}