PHP Function Reference

PHP gethostbyaddr() Function



The PHP gethostbyaddr() function returns the host name of the Internet host specified by the given IP address. The function returns the unmodified ip on failure, or false on malformed input.

Syntax

gethostbyaddr(ip)

Parameters

ip Required. Specify the host IP address.

Return Value

Returns the host name on success, the unmodified ip on failure, or false on malformed input.

Example:

The example below shows the usage of gethostbyaddr() function.

<?php
$ip = gethostbyname('www.alphacodingskills.com');
$hostname = gethostbyaddr($ip);
print_r($hostname);
?>

The output of the above code will be:

131.60.66.34.bc.googleusercontent.com

❮ PHP Network Reference

5