|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #10681 Fix for #9698 breaks more than it fixes
Submitted: 2001-05-05 04:40 UTC Modified: 2001-05-19 20:27 UTC
From: kettler at gmx dot net Assigned:
Status: Closed Package: Network related
PHP Version: 4.0 Latest CVS (05/05/2001) OS: Linux
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If this is not your bug, you can add a comment by following this link.
If this is your bug, but you forgot your password, you can retrieve your password here.
Bug Type:
From: kettler at gmx dot net
New email:
PHP Version: OS:


 [2001-05-05 04:40 UTC] kettler at gmx dot net
$ipaslong = ip2long("");
print long2ip($ipaslong)."\n";
print bin2hex(pack("N", $ipaslong))."\n";

That script run with PHP 4.0.5 prints:

whereas with the latest CVS version it prints:

That makes that function completely unusable for me (and for others probably too). I have another proposal for fixing bug #9698, and that is implementing %u as a sprintf format specifier to output unsigned longs instead of signed.

This way he could use the following script for his problem (should go onto the ip2long page then):
$ip = gethostbyname("");
$out = sprintf("http://%u/<br>\n", ip2long($ip));
echo $out;

If that fix would be accepted (and the other fix rolled back), I could add %u to sprintf myself and post it here.


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2001-05-06 12:00 UTC]
Sounds ok to me, are you willing to make a patch for this?
 [2001-05-06 13:10 UTC] kettler at gmx dot net
Sure. Here it is:

Works for both printf and sprintf. Is there another function I missed?
 [2001-05-09 11:28 UTC]
Someone who knows that part of PHP better should check the 
patch provided. Marked as to be fixed before 4.0.6


 [2001-05-19 20:27 UTC]
I applied the patch, thanks for making it available. The original 'fix'
for bug #9698 has been reversed too. These fixes will be in PHP 4.0.6.

PHP Copyright © 2001-2022 The PHP Group
All rights reserved.
Last updated: Tue Jan 25 14:03:35 2022 UTC