note 21380 rejected from function.ip2long by torben

From: Date: Fri, 10 May 2002 20:00:54 +0000
Subject: note 21380 rejected from function.ip2long by torben
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-30439@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

« previous php.notes (#30439) next »