The PHP Function Ip2long
The php function ip2long converts an IPv4 Internet network address from its Internet standard format (dotted string) representation. It returns a long integer value on success or FALSE if it is invalid.
The function ip2long is useful when working with databases and handling ip addresses. Storing them as decimal numbers rather than the string form will make it much easier to match hostnames with their IP addresses in order to prevent spammers from gaining access to your database and web server. However, storing them as decimal numbers is not ideal if you are trying to match the hostnames with the IP addresses because there are many problems that can arise from doing so such as dropping leading zeros from the first quad of the IP address due to the way that decbin() works and it might not return exactly what is needed for matching purposes.
Also, since decimal numbers are signed integers, some of the values produced by ip2long will be negative. This can be avoided by using the "%u" formatter of sprintf() or printf() to produce a string that will be unsigned when passed through to ip2long.
Another problem is that ip2long and the c linux functions inet_addr and inet_ntoa do not handle ipv6 addresses as well as ipv4 ones. This problem can be resolved by using the ipv6 functions inet_ntop and inet_pton in MySQL which both support ipv6 addresses. Alternatively, you can use the PHP functions inet_addr2 and inet_ntop2.