Home > Backend Development > PHP Tutorial > 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
Release: 2016-07-13 17:17:06
Original
1071 people have browsed it

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

 

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)));...
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template