Phone Number Mobile Number Regular Expression Example_PHP Tutorial

WBOY
Release: 2016-07-20 11:07:18
Original
972 people have browsed it

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:...
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
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!