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():
<?php
$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.
--was--
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.
http://php.net/manual/en/function.ip2long.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.