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";
Keywords
Related Questions
- How can the Content-Type header in HTTP responses be checked in browsers to verify UTF-8 encoding for PHP scripts interacting with LDAP servers?
- What are the potential pitfalls of email headers in PHP and how can they be optimized to pass spam filters?
- How can errors related to database queries be handled effectively in PHP?