Home  >  Article  >  Backend Development  >  When the PHP function ip2long converts IP, the value is too large and a negative number is generated_PHP Tutorial

When the PHP function ip2long converts IP, the value is too large and a negative number is generated_PHP Tutorial

WBOY
WBOYOriginal
2016-07-13 17:17:061056browse

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

 

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/626640.htmlTechArticle// Use sprintf to return an unsigned decimal number $long = sprintf("%u",ip2long($ip) );//Convert to binary first and then to decimal $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