note 21380 added to function.ip2long
| From: | ezequiel at ws4 dot com | Date: | Fri, 10 May 2002 16:50:32 +0000 |
| Subject: | note 21380 added to function.ip2long | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-30429@lists.php.net to get a copy of this message | ||
Im writing a perl function that emulates the ip2long behavior in php... but im astonished to find
that for php ip2long("192.168.0.100") its the same as ip2long("192.168.0.0").
Besides, the underlying algorithm should be something like this (in perl):
sub ip2long($){
my $ipstr=shift;
$ipstr=~ /(\d+).(\d+).(\d+).(\d+)/;
return $4+$3*256+$2*65536+$1*16777216;
}
so, why does php return a value of 4294967295 for ip2long("192.168.0.100") when math
indicates that it should be 3232235620?
the php test script i used was this one:
<?
$a=ip2long("192.168.0.100");
printf("%u\n", ip2long($a));
echo $out;
?>
Thanks a lot
Ezequiel
--
http://www.php.net/manual/en/function.ip2long.php
http://master.php.net/manage/user-notes.php?action=edit+21380
http://master.php.net/manage/user-notes.php?action=delete+21380
http://master.php.net/manage/user-notes.php?action=reject+21380