Php mobile phone number verification Regular Expression

Source: Internet
Author: User

Copy codeThe Code is as follows:
<? Php
// Regular Expression
$ Tel = "15558530459"; // The author's mobile phone number, if you have any questions can contact me by phone, or QQ contact me, My QQ is mezongzi@qq.com
If (strlen ($ tel) = "11 ")
{
// The above part determines whether the length is 11 characters long
$ N = preg_match_all ("/13 [123569] {1} \ d {8} | 15 [1235689] \ d {8} | 188 \ d {8 }/", $ tel, $ array );
/* The subsequent regular expression ("/131,132,133,135,136,139 starts with any 8 followed by a number '|' (OR)
* Any 8 digits starting with 151,152,153,156,158.159
* If the number starts with 188 and then any 8 is a number, matching any group of numbers will pass.
*/")*/

Var_dump ($ array); // check whether it is found. If it is found, the phone number is output.
} Else
{
Echo "the length must be 11 characters ";
}
/*
* Although it looks complicated, it's easy to understand!
* If it is better, you can post it and share your happiness!
**/
?>

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.