Home > Article > Backend Development > How to use regular rules to determine whether it is a mobile phone number in php
This article mainly introduces how to use regular expressions in php to determine whether it is a mobile phone number. Interested friends can refer to it. I hope it will be helpful to everyone.
The code is as follows:
$phonenumber = '13712345678'; if(preg_match("/^1[34578]{1}\d{9}$/",$phonenumber)){ echo "是手机号码"; }else{ echo "不是手机号码"; }
"^" matches the beginning of the text, and "$" matches the end of the text.
Related recommendations:
##PHP regular matching date and time (timestamp conversion) Example code
PHP regular expression to verify email address
php regular expression only retains Chinese alphanumeric characters
The above is the detailed content of How to use regular rules to determine whether it is a mobile phone number in php. For more information, please follow other related articles on the PHP Chinese website!