Are there any best practices for handling domain to IP address conversion in PHP?

When handling domain to IP address conversion in PHP, it is best practice to use the gethostbyname() function provided by PHP. This function takes a domain name as input and returns the corresponding IP address. It handles the DNS resolution internally and can handle both IPv4 and IPv6 addresses.

$domain = "example.com";
$ip = gethostbyname($domain);
echo "The IP address of $domain is: $ip";