note 97982 added to function.ip2long

[email protected]
Newsgroups php.notes
Message-ID <[email protected]>
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
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.