I tried to figure this out on my own but I’m failing. I need a variable to validate as either an IP address or domain name.
Here’s what I ended up with:
if(!filter_var($server_host, FILTER_VALIDATE_IP, FILTER_FLAG_IPV4) AND !filter_var($server_host, FILTER_VALIDATE_DOMAIN)){
echo 'this is not a valid entry';
}
but I can put anything in there and it doesn’t trigger the notification. According to my handiwork, asdfasd asd fasfd ~! is a valid entry.
Well, standard debug technique when it comes to compound logic (X AND Y)… which of the conditions that you were expecting to pass (in this case, fail) did so that you were expecting to do the opposite?
(Hint: I dont think FILTER_VALIDATE_DOMAIN is doing what you think it does. Maybe look at the description again for a further hint?)