Bug #13914: echo ip2long($ip) differs from printf ("%u\n", ip2long ($ip));
| From: | ravenhead at mail dot ru | Date: | Sat, 03 Nov 2001 16:27:21 +0000 |
| Subject: | Bug #13914: echo ip2long($ip) differs from printf ("%u\n", ip2long ($ip)); | ||
| Groups: | php.dev | ||
| Request: | Send a blank email to php-dev+get-69565@lists.php.net to get a copy of this message | ||
From: ravenhead@mail.ru
Operating system: Windows 2000 SP 2
PHP version: 4.0.6
PHP Bug Type: Output Control
Bug description: echo ip2long($ip) differs from printf ("%u\n", ip2long ($ip));
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("www.php.net");
$out = "The following URLs are equivalent:<br>\n";
$out .= "http://www.php.net/, http://".$ip."/, and
http://".ip2long($ip)."/<br>\n";
echo $out;
?>
The output of above is:
////////////////////////////////////////////////////////
The following URLs are equivalent:
http://www.php.net/, http://208.210.50.161/, 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:
<?php
$ip = gethostbyname("www.php.net");
printf ("%u\n", ip2long ($ip));
echo $out;
?>
The output is:
///////////
3503436449
///////////
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.
--
Edit bug report at: http://bugs.php.net/?id=13914&edit=1