PHP Function Reference

PHP gethostbynamel() Function



The PHP gethostbynamel() function returns a list of IPv4 addresses for a given domain/host name. The function returns false if the specified hostname could not be resolved.

Syntax

gethostbynamel(hostname)

Parameters

hostname Required. Specify the host name.

Return Value

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

Example:

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

<?php
$hosts = gethostbynamel('www.alphacodingskills.com');
print_r($hosts);
?>

The output of the above code will be:

Array
(
    [0] => 34.66.60.131
)

❮ PHP Network Reference