AndyXS Posted November 3, 2009 Share Posted November 3, 2009 Here we have two IP filters, without having to do a double if statement, if there an easy way to say.. If valid IP4 or IP6? $ip = '192.168.37'; if(filter_var($ip, FILTER_VALIDATE_IP, FILTER_FLAG_IPV4) === FALSE) // displays IP is not valid { echo 'IP is not valid.'; } else { echo 'IP is valid.'; } $ip = '2001:0cb8:25a3:04c1:1324:8a2b:0471:8221'; if(filter_var($ip, FILTER_VALIDATE_IP, FILTER_FLAG_IPV6) === FALSE) // displays IP is valid { echo 'IP is not valid.'; } else { echo 'IP is valid.'; } Quote Link to comment https://forums.phpfreaks.com/topic/180048-ip4-and-ip6-filter/ Share on other sites More sharing options...
salathe Posted November 3, 2009 Share Posted November 3, 2009 Combine them both into a single if statement using && or AND. Quote Link to comment https://forums.phpfreaks.com/topic/180048-ip4-and-ip6-filter/#findComment-950080 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.