note 10510 deleted from function.long2ip by nlopess
| From: | nlopess@php.net | Date: | Sat, 28 Jan 2006 10:57:10 +0000 |
| Subject: | note 10510 deleted from function.long2ip by nlopess | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-102609@lists.php.net to get a copy of this message | ||
Note Submitter: Joerg Krause (joerg at krause dot net)
----
As shown under ip2long, the function returns signed integer. To use the number as an url, it is
necessary to convert to unsigned integer.
The function long2ip accepts both formats, unsigned and signed integer and produces the same result.
Here is a test and good example:
$ip = "192.168.100.25";
$l = ip2long($ip);
echo "$l ==> " . long2ip($l);
if($l < 0) $l += pow(2,32);
echo "<br>";
echo "$l ==> " . long2ip($l);
Hope this helpy somebody.
Joerg
More PHP: www.php.comzept.de (in german)