Menu Home

inet_ntop

osbo.com | PHP | Functions | inet_ntop

Converts a packed internet address to a human readable representation

Syntax

inet_ntop ( string $in_addr ) : string

Parameters

in_addr

A 32bit IPv4, or 128bit IPv6 address.

Return

Returns a string representation of the address or FALSE on failure.

Examples

1

<?

$packed = chr(127) . chr(0) . chr(0) . chr(1);
$expanded = inet_ntop($packed);
echo $expanded . "\n";

$packed = str_repeat(chr(0), 15) . chr(1);
$expanded = inet_ntop($packed);
echo $expanded;

?>
127.0.0.1
::1

PHP