What is the function gethostbyaddr() used for in PHP?

The gethostbyaddr() function in PHP is used to retrieve the host name corresponding to a given IP address. This can be useful when you have an IP address and need to determine the corresponding domain name. It can also be helpful in reverse DNS lookups.

$ip = '192.168.1.1';
$hostname = gethostbyaddr($ip);
echo "The host name for IP address $ip is: $hostname";