Mobile phone number in PHP regular expression code

Source: Internet
Author: User
Tags php code php regular expression

Mobile (China Mobile phone number):

The code is as follows Copy Code
regexp= "^ ((d{3}) | ( d{3}-))? 13[456789]d{8}|15[89]d{8} "

Verify if the phone number is a regular

The code is as follows Copy Code
: "^ (13[0-9]|15[0|3|6|7|8| 9]|18[6|8| 9]) d{8}$ "

PHP code

The code is as follows Copy Code

<?php
$regex = '/^1 ((3[0-9]) | ( 4[57]) | (5[012356789]) | (8[02356789]) [0-9] {8}$/';

if (Preg_match ($regex, $mobilePhone) = = 0) {
Error
}

Else

{
Echo ' Valid cell phone number ';
}
?>

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.