Home  >  Article  >  Backend Development  >  How to use regular rules to determine whether it is a mobile phone number in php

How to use regular rules to determine whether it is a mobile phone number in php

墨辰丷
墨辰丷Original
2018-05-15 16:28:579471browse

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!

Statement:
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