I m 配对PHP中的Pip地址。 因此,我的检查是:
function checkIP($ip){
$ip = trim($ip);
if (preg_match("(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?).(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?).(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?).(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)", $ip)) return true;
$v6pattern = "/
(A([0-9a-f]{1,4}:){1,1}(:[0-9a-f]{1,4}){1,6})|
(A([0-9a-f]{1,4}:){1,2}(:[0-9a-f]{1,4}){1,5})|
(A([0-9a-f]{1,4}:){1,3}(:[0-9a-f]{1,4}){1,4})|
(A([0-9a-f]{1,4}:){1,4}(:[0-9a-f]{1,4}){1,3})|
(A([0-9a-f]{1,4}:){1,5}(:[0-9a-f]{1,4}){1,2})|
(A([0-9a-f]{1,4}:){1,6}(:[0-9a-f]{1,4}){1,1})|
(A(([0-9a-f]{1,4}:){1,7}|:):)|
(A:(:[0-9a-f]{1,4}){1,7})|
(A((([0-9a-f]{1,4}:){6})(25[0-5]|2[0-4]d|[0-1]?d?d)(.(25[0-5]|2[0-4]d|[0-1]?d?d)){3}))|
(A(([0-9a-f]{1,4}:){5}[0-9a-f]{1,4}:(25[0-5]|2[0-4]d|[0-1]?d?d)(.(25[0-5]|2[0-4]d|[0-1]?d?d)){3}))|
(A([0-9a-f]{1,4}:){5}:[0-9a-f]{1,4}:(25[0-5]|2[0-4]d|[0-1]?d?d)(.(25[0-5]|2[0-4]d|[0-1]?d?d)){3})|
(A([0-9a-f]{1,4}:){1,1}(:[0-9a-f]{1,4}){1,4}:(25[0-5]|2[0-4]d|[0-1]?d?d)(.(25[0-5]|2[0-4]d|[0-1]?d?d)){3})|
(A([0-9a-f]{1,4}:){1,2}(:[0-9a-f]{1,4}){1,3}:(25[0-5]|2[0-4]d|[0-1]?d?d)(.(25[0-5]|2[0-4]d|[0-1]?d?d)){3})|
(A([0-9a-f]{1,4}:){1,3}(:[0-9a-f]{1,4}){1,2}:(25[0-5]|2[0-4]d|[0-1]?d?d)(.(25[0-5]|2[0-4]d|[0-1]?d?d)){3})|
(A([0-9a-f]{1,4}:){1,4}(:[0-9a-f]{1,4}){1,1}:(25[0-5]|2[0-4]d|[0-1]?d?d)(.(25[0-5]|2[0-4]d|[0-1]?d?d)){3})|
(A(([0-9a-f]{1,4}:){1,5}|:):(25[0-5]|2[0-4]d|[0-1]?d?d)(.(25[0-5]|2[0-4]d|[0-1]?d?d)){3})|
(A:(:[0-9a-f]{1,4}){1,5}:(25[0-5]|2[0-4]d|[0-1]?d?d)(.(25[0-5]|2[0-4]d|[0-1]?d?d)){3})
/x";
if (preg_match($v6pattern, $ip)) return true;
return false;
}
然而,I m 发现了一个错误:warning: preg_match (功能.preg-match]:C:xampphtdocsindex. Delimiter绝不能成为甲型数字或反弹。 php on line 5
Line 5 is if (preg_match("(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?).(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?).(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?).(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)", $ip)) return true;
什么错误?