Not so easy in the function below... It is not handling the case of '::' which can happen in an IPv6 and represents any number of 0, addresses could be as simple as ff05::1
![]() |
|
||||||||||
|
inet_pton(PHP 5 >= 5.1.0RC1) inet_pton -- Converts a human readable IP address to its packed in_addr representationDescriptionstring inet_pton ( string address )This function converts a human readable IPv4 or IPv6 address (if PHP was built with IPv6 support enabled) into an address family appropriate 32bit or 128bit binary structure.
See also ip2long(), inet_ntop(), and long2ip(). inet_pton
eric at vyncke org
18-Jul-2007 10:52
Not so easy in the function below... It is not handling the case of '::' which can happen in an IPv6 and represents any number of 0, addresses could be as simple as ff05::1
me at diogoresende dot net
16-May-2006 02:34
If you want to use the above function you should test for ':' character before '.'. Meaning, you should check if it's an ipv6 address before checking for ipv4.
djmaze(AT)dragonflycms(.)org
14-Dec-2005 12:01
If you need the functionality but your PHP version doesn't have the functionality (like on windows) the following might help |