php验证IP地址的方法,供大家参考:
/*
* 验证ip
*/
public function checkIpAddress($ipaddres) {
$preg = “/\A((([0-9]?[0-9])|(1[0-9]{2})|(2[0-4][0-9])|(25[0-5]))\.){3}(([0-9]?[0-9])|(1[0-9]{2})|(2[0-4][0-9])|(25[0-5]))\Z/”;
if (preg_match($preg, $ipaddres) ){
return true;
}else{
return false;
}
}