note 33744 added to function.ip2long

From: Date: Sun, 06 Jul 2003 10:12:19 +0000
Subject: note 33744 added to function.ip2long
Groups: php.notes 
Request: Send a blank email to php-notes+get-51580@lists.php.net to get a copy of this message
if you're using this function to complement mysql's INET_ATON and INET_NTOA it looks like you won't be able to use it. print ip2long("192.168.0.2") returns -1062731774 mysql> SELECT INET_ATON("191.168.0.2") returns 3215458306 i believe these functions should act the same and that mysql's is correct. i want to convert the dotted quad to an int(10) unsigned storable format, but PHP doesn't seem to like the 192.168.0.0/24 block. what i was trying to do was convert the IP in PHP to the long integer and dump it into the DB. PHP and MySQL calculate 10.0.0.2 the same. so it's not a non-routable block issue. they also calculate my public internet IP properly. it's this 192.168.0.* issue that i don't believe is correct. i don't see why PHP would be returning a negative number, the number should be between 0 and 4294967295 (or -1 just for the 255.255.255.255 issue..) ---- Manual Page -- http://www.php.net/manual/en/function.ip2long.php Edit Note -- http://master.php.net/manage/user-notes.php?action=edit+33744 Delete Note -- http://master.php.net/manage/user-notes.php?action=delete+33744&report=yes Reject Note -- http://master.php.net/manage/user-notes.php?action=reject+33744&report=yes

« previous php.notes (#51580) next »