Home > Article > Backend Development > PHP verifies whether the entered mobile phone number is legal
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; }
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!