Can someone please comment if the following code will be suitable for detecting if I am dealing with an IPv6 address? I am worried about this because I know very little about IPv6 and have never knowingly encountered one.
$ip = $_SERVER['REMOTE_ADDR'];
if (strlen($ip) >= 16)
{
// found IPv6 address
}
I want the code in the if statement to execute if $ip yields an ipv6 addresses. Normal v4 IPS max out at 15 characters, I believe. (255.255.255.255)
[TABLE=“class: doctable table, width: 0”]
[TR]
[TD=“bgcolor: #F0F0F0, align: left”]FILTER_FLAG_IPV4[/TD]
[TD=“bgcolor: #F0F0F0, align: left”]FILTER_VALIDATE_IP[/TD]
[TD=“bgcolor: #F0F0F0, align: left”]Allows the IP address to be in IPv4 format.[/TD]
[/TR]
[TR]
[TD=“bgcolor: #F0F0F0, align: left”]FILTER_FLAG_IPV6[/TD]
[TD=“bgcolor: #F0F0F0, align: left”]FILTER_VALIDATE_IP[/TD]
[TD=“bgcolor: #F0F0F0, align: left”]Allows the IP address to be in IPv6 format.[/TD]
[/TR]
[/TABLE]