PHP
1 2 3 4 |
$ip = "10.3.1.5"; if(!filter_var($ip, FILTER_VALIDATE_IP)) { echo "Not a valid IP address!"; } |
--
Python
使用 try 測試 ip 是否正確
1 2 3 4 5 |
import ipaddress try: print(ipaddress.IPv4Address('192.168.1.234')) except Exception as e: print('ip error') |
--
787 total views, 1 views today