PHP verifies whether the entered mobile phone number is legal

小云云
Release: 2023-03-20 22:58:02
Original
5587 people have browsed it

This article mainly shares with you the example code of PHP verifying whether the entered mobile phone number is legal. I hope it can help everyone.

function is_mobile_phone ($mobile_phone)
{
    
    $chars = "/^13[0-9]{1}[0-9]{8}$|15[0-9]{1}[0-9]{8}$|18[0-9]{1}[0-9]{8}$|17[0-9]{1}[0-9]{8}$/";
    if(preg_match($chars, $mobile_phone))
    {
        return true;
    }
    
    return false;
}
Copy after login

Related recommendations:

AngularJS implements form verification mobile phone number function

How jQuery uses regular expressions to verify mobile phone numbers and ID cards Number, Chinese name

javascript - Problem with regular verification of mobile phone number

The above is the detailed content of PHP verifies whether the entered mobile phone number is legal. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template