Skip to content

Instantly share code, notes, and snippets.

@ademalp
Created February 4, 2013 12:05
Show Gist options
  • Save ademalp/4706371 to your computer and use it in GitHub Desktop.
Save ademalp/4706371 to your computer and use it in GitHub Desktop.
<?php
$ip_adresleri = array(
"2607:f0d0:1002:51::4",
"2607:f0d0:1002:0051:0000:0000:0000:0004",
"212.20.19.10",
"212.0.1",
"212.a.b.112"
) ;
foreach($ip_adresleri as $ip_adresi)
{
if(filter_var($ip_adresi,FILTER_VALIDATE_IP,FILTER_FLAG_IPV6))
{
echo "$ip_adresi - IPv6\n";
}
elseif(filter_var($ip_adresi,FILTER_VALIDATE_IP,FILTER_FLAG_IPV4))
{
echo "$ip_adresi - IPv4\n";
}else
{
echo "$ip_adresi - Geçersiz\n";
}
}
2607:f0d0:1002:51::4 - IPv6
2607:f0d0:1002:0051:0000:0000:0000:0004 - IPv6
212.20.19.10 - IPv4
212.0.1 - Geçersiz
212.a.b.112 - Geçersiz
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment