|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #42512 ip2long('') should return 4294967295 on 64-bit PHP
Submitted: 2007-09-01 18:10 UTC Modified: 2007-09-01 18:38 UTC
From: jr-php2 at quo dot to Assigned: derick
Status: Closed Package: Network related
PHP Version: 5.2.4 OS: Linux x86-64
Private report: No CVE-ID:
 [2007-09-01 18:10 UTC] jr-php2 at quo dot to
On 64-bit platforms, ip2long() returns a positive result for IP addresses >= This is expected.

However, there is *one* case in which it will return a negative result: when the specified address is

This inconsistency doesn't make sense. Yes, the documentation does say that ip2long() returns -1 for, but that should only be the case on 32-bit platforms, where all addresses >= return a negative result.

Reproduce code:
echo "ip2long('') = ", ip2long(''), "\n";
echo "ip2long('') = ", ip2long(''), "\n";

Expected result:
ip2long('') = 4294967294
ip2long('') = 4294967295

Actual result:
ip2long('') = 4294967294
ip2long('') = -1


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2007-09-01 18:29 UTC]
Confirmed, and testing a patch.
 [2007-09-01 18:38 UTC]
This bug has been fixed in CVS.

Snapshots of the sources are packaged every three hours; this change
will be in the next snapshot. You can grab the snapshot at
Thank you for the report, and for helping us make PHP better.
PHP Copyright © 2001-2015 The PHP Group
All rights reserved.
Last updated: Mon Nov 30 08:01:52 2015 UTC