prabhuram.k@gma il.com wrote:[color=blue]
> Can anybody know how to validate IPV4 and IPV6 address in PHP. I am
> using PHP 4.2.3 for some compatiability reason.
>[/color]
// Checks whether a given IPv6 address string could be valid based on
full and compressed IPv6 addresses as defined in RFC 2373 - http://www.faqs.org/rfcs/rfc2373.html
// Regex by Jeff Johnson
// http://www.regxlib.com/REDetails.aspx?regexp_id=1000
$pattern[ipv6] =
'/^((([0-9A-Fa-f]{1,4}:){7}[0-9A-Fa-f]{1,4})|(([0-9A-Fa-f]{1,4}:){6}:[0-9A-Fa-f]{1,4})|(([0-9A-Fa-f]{1,4}:){5}:([0-9A-Fa-f]{1,4}:)?[0-9A-Fa-f]{1,4})|(([0-9A-Fa-f]{1,4}:){4}:([0-9A-Fa-f]{1,4}:){0,2}[0-9A-Fa-f]{1,4})|(([0-9A-Fa-f]{1,4}:){3}:([0-9A-Fa-f]{1,4}:){0,3}[0-9A-Fa-f]{1,4})|(([0-9A-Fa-f]{1,4}:){2}:([0-9A-Fa-f]{1,4}:){0,4}[0-9A-Fa-f]{1,4})|(([0-9A-Fa-f]{1,4}:){6}((\b( (25[0-5])|(1\d{2})|(2[0-4]\d)|(\d{1,2}))\ b)\.){3}(\b((25[0-5])|(1\d{2})|(2[0-4]\d)|(\d{1,2}))\ b))|(([0-9A-Fa-f]{1,4}:){0,5}:(( \b((25[0-5])|(1\d{2})|(2[0-4]\d)|(\d{1,2}))\ b)\.){3}(\b((25[0-5])|(1\d{2})|(2[0-4]\d)|(\d{1,2}))\ b))|(::([0-9A-Fa-f]{1,4}:){0,5}((\ b((25[0-5])|(1\d{2})|(2[0-4]\d)|(\d{1,2}))\ b)\.){3}(\b((25[0-5])|(1\d{2})|(2[0-4]\d)|(\d{1,2}))\ b))|([0-9A-Fa-f]{1,4}::([0-9A-Fa-f]{1,4}:){0,5}[0-9A-Fa-f]{1,4})|(::([0-9A-Fa-f]{1,4}:){0,6}[0-9A-Fa-f]{1,4})|(([0-9A-Fa-f]{1,4}:){1,7}:)) $/';
Pass the value to be tested to the below as $value:
Comment