What function in PHP can be used to retrieve the IP address of a domain?

To retrieve the IP address of a domain in PHP, you can use the `gethostbyname()` function. This function takes a domain name as a parameter and returns the corresponding IP address. This can be useful for various purposes such as checking the IP address of a domain before making a connection or logging visitor IPs on a website.

$domain = "example.com";
$ip_address = gethostbyname($domain);

echo "The IP address of $domain is: $ip_address";