SQL PHP HTML ASP JavaScript articles and free scripts to download
PHP Filter

FILTER_VALIDATE_IP

FILTER_VALIDATE_IP can be used to validate IP address ( both IPv4 and IPv6 ) . This filter id = 275. Here is the code.
$ip="255.255.47.12";
if(filter_var($ip,FILTER_VALIDATE_IP)){
echo " Correct , validation passed";
}else{
echo " Wrong , validation failed ";
}
To check IPV6 we can add optional flag like this
if(filter_var($ip,FILTER_VALIDATE_IP,FILTER_FLAG_IPV6)){
echo " Correct , validation passed";
}else{
echo " Wrong , validation failed ";
}

Be the first to post comment on this article :


Google+
Post Comment This is for short comments only. Use the forum for more discussions.
Name
Email( not to be displayed)Privacy Policy
1+2=This is to prevent automatic submission by spammers. Please enter the result of the sum as asked



HTML . MySQL. PHP. JavaScript. ASP. Photoshop. Articles. FORUM Contact us

©2000-2014 plus2net.com All rights reserved worldwide Privacy Policy Disclaimer