Home  >  Article  >  Backend Development  >  Phone Number Mobile Number Regular Expression Example_PHP Tutorial

Phone Number Mobile Number Regular Expression Example_PHP Tutorial

WBOY
WBOYOriginal
2016-07-20 11:07:18972browse

Phone number mobile phone number regular expression example




Phone number mobile number regular expression example




Input 13875998850
Output valid contact information

Enter 0136986+9557
There is a problem with outputting contact information


function funcPhone( $str)//Telephone number regular expression try
{
return (preg_match("/^(((d{3}))|(d{3}-))?((0d{2,3 })|0d{2,3}-)?[1-9]d{6,8}$/",$str))?true:false;
}  

function funcMtel($ str)//Mobile phone number regular expression try
{
return (preg_match("/(?:13d{1}|15[03689])d{8}$/",$str))?true: false;
}


if( $_POST)
{
if( funcPhone( $_POST['url'] ) || funcMtel( $_POST['url'] ) )
{
echo 'Valid contact information';
}
else
{
exit('There is a problem with the contact information');
}
}
?>


www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/444971.htmlTechArticlePhone number mobile number regular expression example! DOCTYPE html PUBLIC -//W3C//DTD XHTML 1.0 Transitional// EN http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd html xmlns=http:...
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