Edit report at https://bugs.php.net/bug.php?id=64395&edit=1
ID: 64395 Updated by: a...@php.net Reported by: abc905 at mail dot ru Summary: Wrong result -Status: Open +Status: Wont fix Type: Bug Package: Network related Operating System: Windows 7 x64 PHP Version: 5.4.13 Block user comment: N Private report: N New Comment: This won't fix in 5.4 - the native inet_pton platform implementation is available starting with windows vista http://msdn.microsoft.com/en-us/library/windows/desktop/cc805844(v=vs.85).aspx , in 5.4 however windows xp support is guaranteed. In 5.5 the sdk implementation is used, which validates this issue as fixed there. Prior to that PHP own inet_pton implementation is used, which isn't perfect. However the case you brought is just one of many more complicated, imagine one would use a hex notation for segments including upper and lower letter case. Parsing this is much more complicated and facing the fact it's fixed in 5.5 I'm really not sure it's worth to touch 5.4. Previous Comments: ------------------------------------------------------------------------ [2013-04-21 12:37:40] sjon at hortensius dot net 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 ------------------------------------------------------------------------ [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