gethostbynamel()

gethostbynamel() — Get a list of IPv4 addresses corresponding to a given Internet host name.

Built-in function of PHP 8.5. The manual lists it as available in PHP 4, PHP 5, PHP 7, PHP 8. This page is the reference card: signature, parameters and return value, plus the changelog and the example the manual provides.

Signature

gethostbynamel(string $hostname): array|false

Parameters

ParameterTypeWhat it takes
$hostnamestringThe host name.

Return value

Returns an array of IPv4 addresses or false if hostname could not be resolved.

Example

A runnable snippet:

$hosts = gethostbynamel('www.example.com'); print_r($hosts);

Output:

Array ( [0] => 192.0.34.166 )

See also

gethostbyname(), gethostbyaddr(), checkdnsrr(), getmxrr()

All PHP 8.5 built-in functions

Reference card built from the PHP manual page gethostbynamel() (PHP documentation, CC BY 3.0). The page is generated from the manual, so the wording of the parameter and return value text follows php.net.