Current Location: Home> Function Categories> inet_ntop

inet_ntop

Convert packaged Internet addresses to human-readable representations
Name:inet_ntop
Category:Network
Programming Language:php
One-line Description:Convert a 32-bit IPv4 or 128-bit IPv6 address to a readable format.

Definition and usage

inet_ntop() function converts a 32-bit IPv4 or 128-bit IPv6 address into a readable format.

Example

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

Example explanation

$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.

grammar

 inet_ntop ( address )

Parameter value

parameter describe
address Required. Specifies a 32-bit IPv4 or 128-bit IPv6 address.
Similar Functions
Popular Articles