The inet_ntop() function is an inbuilt function in PHP which converts a 32bit IPv4 or 128bit IPv6 address into a readable format.
Syntax:
php
php
string inet_ntop( string $ip_address )Parameter: This function accepts one parameter as mentioned above and described below:
- $ip_address: It is required parameter. It specifies a 32bit IPv4 or 128bit IPv6 address.
<?php
// Store the address into variable
$addr = chr(127) . chr(0) . chr(1) . chr(1);
// Use inet_ntop() function to convert
// internet address to a human readable
// representation
$exp = inet_ntop($addr);
// Display result
echo $exp;
?>
Output:
Program 2: This program uses a string of size 4 of ascii characters directly in the parameter.
127.0.1.1
<?php
// Use inet_ntop() function to convert
// internet address to a human readable
// representation
echo inet_ntop("[][]") . "<br>";
echo inet_ntop("4509") . "<br>";
echo inet_ntop("*^b@") . "<br>";
echo inet_ntop("hqp0") . "<br>";
echo inet_ntop("2c#!");
?>
Output:
Reference: https://www.php.net/manual/en/function.inet-ntop.php91.93.91.93
52.53.48.57
42.94.98.64
104.113.112.48
50.99.35.33