|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #13916 echo ip2long($ip) differs from printf ("%u\n", ip2long ($ip));
Submitted: 2001-11-03 11:28 UTC Modified: 2001-11-03 11:33 UTC
From: ravenhead at mail dot ru Assigned:
Status: Not a bug Package: Output Control
PHP Version: 4.0.6 OS: Windows 2000 SP 2
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: ravenhead at mail dot ru
New email:
PHP Version: OS:


 [2001-11-03 11:28 UTC] ravenhead at mail dot ru
There are two examples in PHP MANUAL of ip2long() usage.
The first one is based on echo output and the second - on printf() function. These are examples with output:

$ip = gethostbyname("");
$out = "The following URLs are equivalent:<br>\n";
$out .= ", http://".$ip."/, and http://".ip2long($ip)."/<br>\n";
echo $out;

The output of above is:
The following URLs are equivalent:,, and http://-791530847/

I was confused on $ip output (i supposed ip-numbers are unsigned integers and cannot contain negative values like -791530847, echoed above). So, i've tryed to run the second example, wich uses printf() function:

$ip = gethostbyname("");
printf ("%u\n", ip2long ($ip));
echo $out;

The output is:

I've changed code different ways, 've restarted machine, Apache server, but the difference remains. So, i've decided it's a bug either of echo or of ip2long() functions.


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2001-11-03 11:33 UTC]
Multiple submissions => Bogus
PHP Copyright © 2001-2023 The PHP Group
All rights reserved.
Last updated: Tue Oct 03 08:01:24 2023 UTC