|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #25612 ip2long() and long2ip() results differs.
Submitted: 2003-09-20 02:30 UTC Modified: 2003-09-20 10:47 UTC
From: marrtins at hackers dot lv Assigned:
Status: Not a bug Package: *Network Functions
PHP Version: 4.3.1 OS: Linux 2.4.20
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
Block user comment
Status: Assign to:
Bug Type:
From: marrtins at hackers dot lv
New email:
PHP Version: OS:


 [2003-09-20 02:30 UTC] marrtins at hackers dot lv
Should ip address '' differ from '' ? I think not. Please check it out!

Reproduce code:

printf("%u\n", ip2long('')); // 1055581472
print long2ip('1055581472')."\n"; //
printf("%u\n", ip2long('')); // 1055581480


Expected result:

Actual result:


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2003-09-20 07:00 UTC]
040 is octal for 32.
 [2003-09-20 10:47 UTC]
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at and the instructions on how to report
a bug at

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" will try to ping
PHP Copyright © 2001-2021 The PHP Group
All rights reserved.
Last updated: Wed Jan 20 13:01:28 2021 UTC