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 "; }
0 comments:
Post a Comment