[PHP-DEV] Bug #10924: long2ip gives wrong result/binary arithmatic does not work From: richarde <email protected>
Date: 05/17/01

From: richarde <email protected>
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

-- PHP Development Mailing List <http://www.php.net/> To unsubscribe, e-mail: php-dev-unsubscribe <email protected> For additional commands, e-mail: php-dev-help <email protected> To contact the list administrators, e-mail: php-list-admin <email protected>