Edit report at https://bugs.php.net/bug.php?id=64395&edit=1
ID: 64395 Comment by: sjon at hortensius dot net Reported by: abc905 at mail dot ru Summary: Wrong result Status: Open Type: Bug Package: Network related Operating System: Windows 7 x64 PHP Version: 5.4.13 Block user comment: N Private report: N New Comment: Php interprets numbers with leading zeros as octal [1]. Octal 011 = Decimal 9. Also, I think this is not a valid IP address notation. This is fixed in newer PHP versions, where this format is rejected and false is returned; see http://3v4l.org/EBD9k 1. http://php.net/manual/en/language.types.integer.php Previous Comments: ------------------------------------------------------------------------ [2013-03-28 15:48:28] abc905 at mail dot ru PHP. Ver. 5.4.13 (Open Server Win7 x64) Output: 1.1.011.011 -> 1.1.9.9 1.1.071.071 -> 1.1.57.57 1.1.081.081 -> 0.0.0.0 Looks like long2ip() converts segments with leading zero as octal. ------------------------------------------------------------------------ [2013-03-21 16:11:01] abc905 at mail dot ru Unfortunatly my output is wrong PHP. Ver. 5.4.11 (Open Server Win7 x64) and 5.4.9 (Windows Installer install) Output: 1.1.011.011 -> 1.1.9.9 1.1.071.071 -> 1.1.57.57 1.1.081.081 -> 0.0.0.0 Looks like long2ip() converts segments with leading zero as octal. ------------------------------------------------------------------------ [2013-03-17 02:39:34] pete at petermcdonald dot co dot uk I have tried to reproduce on php 5.4.11 (zend server install) using code specified but output is expected 1.1.11.11. ------------------------------------------------------------------------ [2013-03-08 19:54:51] abc905 at mail dot ru Description: ------------ Hello, It seems ip2long function returns wrong result 1.1.9.9 instead of 1.1.11.11 when convert ip address like '1.1.011.011' Thank you, Alexander --- >From manual page: http://www.php.net/function.long2ip --- Test script: --------------- $ip = '1.1.011.011'; $ip_long = sprintf("%u", ip2long($ip)); print long2ip($ip_long); ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=64395&edit=1