Back to examples |
Take an IP address in xxx.xxx.xxx.xxx format and converts it to an integer value. The addition in this routine makes sure the returned number is a positive value, which allows for easier handling of comparisions on the integer value if the original IP is greater than 127.255.255.255.
|
<?php // We will user the remote IP for this example
$ip2 = ip2long($REMOTE_ADDR);
if ($ip2 < 0) $ip2 += pow(2,32);
print($ip);
?>
|
|
|