Home > php教程 > php手册 > 手机号码验证判断php函数实例讲解

手机号码验证判断php函数实例讲解

WBOY
Release: 2016-06-13 10:39:00
Original
1193 people have browsed it

手机号码验证判断php函数

  1.  function checkMobile($str)
  2.  {
  3.      $pattern = "/^(13|15)d{9}$/";
  4.      if (preg_match($pattern,$str))
  5.      {
  6.           Return true;
  7.      }
  8.      else
  9.      {
  10.          Return false;
  11.      }
  12.  }
  13. //调用函数
  14. $str = checkMobile("15800000001");
  15.  if($str)
  16.  {
  17.  echo("符合手机号码标准");
  18.  }
  19.  else
  20.  {
  21.  echo("不符合手机号码标准");
  22.  }
  23. ?>

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template