Bug #10924: long2ip gives wrong result/binary arithmatic does not work
| From: | richarde at eskom dot co dot za | Date: | Thu, 17 May 2001 13:24:07 +0000 |
| Subject: | Bug #10924: long2ip gives wrong result/binary arithmatic does not work | ||
| Groups: | php.dev | ||
| Request: | Send a blank email to php-dev+get-55615@lists.php.net to get a copy of this message | ||
From: richarde@eskom.co.za
Operating system: Linux Redhat 6.2
PHP version: 4.0.4pl1
PHP Bug Type: Network related
Bug description: long2ip gives wrong result/binary arithmatic does not work
$x = 2473473034; // 147.110.52.10 in int form
settype($x, "integer"); // this line has no effect on final result of long2ip
echo "long ".is_long($x);
echo "<P>";
$y = ip2long("147.110.52.10");
echo "long ".is_long($y);
echo "<P>";
echo ip2long("147.110.52.10"); // should be 2473473034
echo "<P>";
echo long2ip($y); // correct result here
echo "<P>";
echo long2ip($x); // wrong result
echo "<P>";
echo $y & 127; // correct result
echo "<P>";
echo $x & 127; // incorrect result - should be 10
echo "<P>";
**** cut ****
basically there is no way to do ip arithmatic using php - I cannot get large numbers like ip
addresses from a database stored as integers and minipulate them - AND, OR and XOR do not work on
large number as in example.
--
Edit Bug report at: http://bugs.php.net/?id=10924&edit=1