How to use inet_ntop() function to convert internet package to human readable format in PHP

2 Answers

0 votes
$packed = chr(127) . chr(0) . chr(0) . chr(1);
echo $packed . "<br />";
$s = inet_ntop($packed);
echo $s . "<br />";

   
/*
run: 


127.0.0.1

*/

 



answered May 11, 2016 by avibootz
0 votes
$packed = str_repeat(chr(0), 15) . chr(1);
echo $packed . "<br />";
$s = inet_ntop($packed);
echo $s . "<br />";

   
/*
run: 


::1

*/

 



answered May 11, 2016 by avibootz
...