美文网首页
php 正则验证ip

php 正则验证ip

作者: chinariver | 来源:发表于2017-06-28 14:48 被阅读0次

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;

           }

}

相关文章

网友评论

      本文标题:php 正则验证ip

      本文链接:https://www.haomeiwen.com/subject/sryucxtx.html