ID: 10924
Updated by: derick
Old-Status: Open
Status: Suspended
Bug Type: Network related
Operating system: 
PHP Version: 4.0.4pl1
Assigned To: 

There is no solution for this, because PHP only deals with signed longs.
However, you can now use the %u modifier in printf and sprintf to show a long unsigned 
number like this:

    printf ("%u\n", ip2long (""));


I suspended this bug, until unsigned longs are really working (there are some feature 
request for this already).


Previous Comments:

[2001-05-17 09:24:07] [EMAIL PROTECTED]
$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.


ATTENTION! Do NOT reply to this email!
To reply, use the web interface found 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