PHP(RegEx)电话号码验证

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了PHP(RegEx)电话号码验证相关的知识,希望对你有一定的参考价值。

A simple method of validating a telephone number using regular expressions and php
  1. $string = "(232) 555-5555";
  2. if (preg_match('/^(?[0-9]{3})?|[0-9]{3}[-. ]? [0-9]{3}[-. ]?[0-9]{4}$/', $string)) {
  3. echo "example 2 successful.";
  4. }

以上是关于PHP(RegEx)电话号码验证的主要内容,如果未能解决你的问题,请参考以下文章