#25612 [Opn->Bgs]: ip2long() and long2ip() results differs.
| From: | iliaa@php.net | Date: | Sat, 20 Sep 2003 14:47:51 +0000 |
| Subject: | #25612 [Opn->Bgs]: ip2long() and long2ip() results differs. | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-47876@lists.php.net to get a copy of this message | ||
ID: 25612
Updated by: iliaa@php.net
Reported By: marrtins at hackers dot lv
-Status: Open
+Status: Bogus
Bug Type: *Network Functions
Operating System: Linux 2.4.20
PHP Version: 4.3.1
New Comment:
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.php.net/manual/ and the instructions on how to
report
a bug at http://bugs.php.net/how-to-report.php
Like wez said, prefixing the IP portion with a 0 makes PHP think the
number is in octal and not decimal form. This is not unique to PHP,
"ping 62.234.229.040" will try to ping 62.234.229.32.
Previous Comments:
------------------------------------------------------------------------
[2003-09-20 07:00:19] wez@php.net
040 is octal for 32.
------------------------------------------------------------------------
[2003-09-20 02:30:41] marrtins at hackers dot lv
Description:
------------
Should ip address '62.234.229.040' differ from '62.234.229.40' ? I
think not. Please check it out!
Reproduce code:
---------------
<?php
printf("%u\n", ip2long('62.234.229.040')); // 1055581472
print long2ip('1055581472')."\n"; // 62.234.229.32
printf("%u\n", ip2long('62.234.229.40')); // 1055581480
?>
Expected result:
----------------
1055581480
62.234.229.32
1055581480
Actual result:
--------------
1055581472
62.234.229.32
1055581480
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=25612&edit=1