Answers for "check if is a valid ip"

PHP
2

Validate IP Address

try:
            if len(IP.split('.')) == 4:
                print(IP)
                if all([bool(1) if(str(int(s)) == s and 0 <= int(s) <= 255) else bool(0) for s in IP.split('.')]):
                    return "IPv4"
            if len(IP.split(':')) == 8:
                if all([bool(1) if(len(s) <= 4 and int(s, 16) >= 0) else bool(0) for s in IP.split(':')]):
                    return "IPv6"
        except:
            return "Neither"
        return "Neither"
Posted by: Guest on August-03-2020
0

if ip is

if($_SERVER["REMOTE_ADDR"]=='111.111.111.111'){
//run only my ip
}
Posted by: Guest on October-08-2021

Browse Popular Code Answers by Language