inet_ntop
Convert packaged Internet addresses to human-readable representations
inet_ntop()
function converts a 32-bit IPv4 or 128-bit IPv6 address into a readable format.
Convert packaged addresses to readable format:
<?php $addr = chr ( 127 ) . chr ( 0 ) . chr ( 1 ) . chr ( 1 ) ; $exp = inet_ntop ( $addr ) ; echo $exp ; ?>
Try it yourself
$addr
is a string composed of four characters that represent four bytes of a 32-bit IPv4 address (127.0.1.1 here). The inet_ntop()
function converts this string into a human-readable IP address and stores the result in $exp
. Then, output this result through the echo
statement.
inet_ntop ( address )
parameter | describe |
---|---|
address | Required. Specifies a 32-bit IPv4 or 128-bit IPv6 address. |