php ip2long 负数问题

官方网站:

Note:

因为PHP的 integer 类型是有符号,并且有许多的IP地址讲导致在32位系统的情况下为负数, 你需要使用 "%u" 进行转换通过 sprintf() 或 printf() 得到的字符串来表示无符号的IP地址。

$ip = sprintf("%u",ip2long($ip));

  

其他方法见链接:

 https://blog.csdn.net/everything1209/article/details/22418559

 

原文地址:https://www.cnblogs.com/cbugs/p/9489046.html