note 97982 added to function.ip2long

From: Date: Wed, 19 May 2010 10:37:38 +0000
Subject: note 97982 added to function.ip2long
Groups: php.notes 
Request: Send a blank email to php-notes+get-169404@lists.php.net to get a copy of this message
I would just like to try and clear up simply that if storing IPV4 addresses in an SQL database you should use an unsigned int (4 bytes). The easiest way to do this in PHP is to use sprintf(): $dottedFormatAddress = '127.0.0.1'; $ipv4address = sprintf("%u", ip2long($dottedFormatAddress)); Primary reasons are it's compatible with database functions like MySQL's INET_ATON & INET_NTOA (which also use unsigned int's), it's efficient, and it's the most common format used by IP lookup databases. ---- Server IP: 69.147.83.197 Probable Submitter: 78.105.235.11 ---- Manual Page -- http://www.php.net/manual/en/function.ip2long.php Edit -- https://master.php.net/note/edit/97982 Del: integrated -- https://master.php.net/note/delete/97982/integrated Del: useless -- https://master.php.net/note/delete/97982/useless Del: bad code -- https://master.php.net/note/delete/97982/bad+code Del: spam -- https://master.php.net/note/delete/97982/spam Del: non-english -- https://master.php.net/note/delete/97982/non-english Del: in docs -- https://master.php.net/note/delete/97982/in+docs Del: other reasons-- https://master.php.net/note/delete/97982 Reject -- https://master.php.net/note/reject/97982 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#169404) next »