当前位置:网站首页>Ip2long and long2ip analysis

Ip2long and long2ip analysis

2022-07-07 12:51:00 Full stack programmer webmaster

<?php

$ip='47.93.97.127';
$long=sprintf("%u",ip2long($ip));//string(9) "794648959"   9 position 
var_dump($long);

echo "<br>";
$ip='247.193.197.127';
$long=ip2long($ip);//int(-138295937) 
var_dump($long);


echo "<br>";
$ip='247.193.197.127';
$long2=sprintf("%u",ip2long($ip));
var_dump($long2);      //string(10) "4156671359"  10 position 
echo "<br>";
var_dump(long2ip($long2));//string(15) "247.193.197.127" 

$ip=’47.93.97.127′; as long as 47 Change to three digits , After converting to an integer, it is 10 position , need sprintf Function transformation , Otherwise, negative numbers appear

Publisher : Full stack programmer stack length , Reprint please indicate the source :https://javaforall.cn/113446.html Link to the original text :https://javaforall.cn

原网站

版权声明
本文为[Full stack programmer webmaster]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/188/202207071036122201.html