Home  >  Article  >  php教程  >  PHP函数ip2long转换IP时数值太大而产生负数

PHP函数ip2long转换IP时数值太大而产生负数

WBOY
WBOYOriginal
2016-06-13 10:17:391542browse

// 使用 sprintf 返回无符号十进制数
$long = sprintf("%u",ip2long($ip));
// 先转换为二进制然后在转换为十进制
$long = bindec(decbin(ip2long($ip)));

  

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn