Let's take a look at the following PHP code. This section uses the ip2long function to convert the same IP address. Of course, some people think that 58.99000011.1 and 058.99000011.1 are not legal.
IP, then return. This article does not help you.
Why use IP addresses with leading zeros? to query in the database, you can locate the IP address location information in the IP address library. Although it is highly efficient to Query IP addresses without integer types, it is intuitive after all.
<? Php <br/> echo ip2long ('58. 99.11.1 '), "<br/>"; // The output is 979569409 <br/> echo ip2long ('58. 992.1611.1 '), "<br/>"; // The output is 979568897 <br/> echo ip2long ('058. 99.11.1 '), "<br/>"; // The output is empty <br/>?> </P> <p>
In PHP 4.X, 5.x, IP address conversion results with leading zeros are incorrect.
Solution: Use your own function:
Function myip2long ($ IP) {<br/> $ ip_arr = Split ('/. ', $ IP); <br/> $ iplong = (16777216 * intval ($ ip_arr [0]) + (65536 * intval ($ ip_arr [1]) + (256 * intval ($ ip_arr [2]) + intval ($ ip_arr [3]); <br/> return $ iplong; <br/>}