From:             [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;         // 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("");
echo "long ".is_long($y);
echo "<P>";

echo ip2long("");  // 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:

PHP Development Mailing List <>
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]

Reply via email to