Home  >  Article  >  Backend Development  >  Mobile phone number verification and judgment PHP function example explanation_PHP tutorial

Mobile phone number verification and judgment PHP function example explanation_PHP tutorial

WBOY
WBOYOriginal
2016-07-13 17:40:32961browse

Mobile phone number verification judgment php function

  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. //Call function
  14. $str = checkMobile("15800000001");
  15. if($str)
  16. {
  17. echo ("Conforms to mobile phone number standards");
  18. }
  19. else
  20. {
  21. echo("Does not meet mobile phone number standards");
  22. }
  23. ?>

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/486215.htmlTechArticleMobile phone number verification and judgment php function?php function checkMobile($str) { $pattern = "/^(13| 15)d{9}$/"; if (preg_match($pattern,$str)) { Return true; } else { Return false; } } //Call function...
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