Home >php教程 >php手册 >php 验证手机号码与电话号码正则

php 验证手机号码与电话号码正则

WBOY
WBOYOriginal
2016-06-13 10:59:05985browse

function funcphone($str)//电话号码正则表达试
{
 return (preg_match("/^(((d{3}))|(d{3}-))?((0d{2,3})|0d{2,3}-)?[1-9]d{6,8}$/",$str))?true:false;
} //使用方法

if( funcphone ('0731-88888888'))
{
 echo '正确电话号码';
}
else
{
 echo '对不起,您输入的电话号码不正确';
}


function funcmtel($str)//手机号码正则表达试
{
 return (preg_match("/(?:13d{1}|15[03689])d{8}$/",$str))?true:false;
}

//手机号验证应用

if( funcmtel( '13875888888') )
{
 echo '你输入手机号码是正确的';
}
else
{
 echo '请输入合法中国移动或联动手机号';
}

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