Home  >  Article  >  Backend Development  >  PHP regular expression to verify mobile phone number

PHP regular expression to verify mobile phone number

WBOY
WBOYOriginal
2016-07-25 09:13:151244browse

Example, php regular expression to verify mobile phone and phone number.

  1. function check_telnum1($telnum)
  2. {
  3. $b1 = (preg_match("/^(0[0-9]{2,3}[-]?[2-9] [0-9]{6,7}[-]?[0-9]?)$/i",$telnum))?TRUE:FALSE;// Phone
  4. $b2 = (preg_match("/^(1 [358]{1}[0-9]{9})$/i",$telnum))?TRUE:FALSE;//Mobile phone
  5. return $b1 || $b2;
  6. }
Copy code


Statement:
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