PHP头条
热点:

php邮箱,网址,手机号码合法性正则


php 邮箱,网址,手机号码合法性正则 有需要的朋友可参考一下

1. 判断Email:

代码如下

function is_email($email){
return strlen($email) > 6 && preg_match("/^[w-.]+@[w-]+(.w+)+$/", $email);
}
?>

2. 判断Url:

代码如下

function is_url(http://pic3.phprm.com/2012/10/12/$str.jpg){
return preg_match("/^http://[A-Za-z0-9]+.[A-Za-z0-9]+[/=?%-&_~`@[]':+!]*([^<>"])*$/", $str);
}

3. 判断手机号码:

代码如下

function is_mobile($str){
return preg_match("/^(((d{3}))|(d{3}-))?13d{9}$/", $str);
}



永久链接:

转载随意!带上文章地址吧。

www.phpzy.comtrue/phpyy/46505.htmlTechArticlephp邮箱,网址,手机号码合法性正则 php 邮箱,网址,手机号码合法性正则 有需要的朋友可参考一下 1. 判断Email: 代码如下 function is_email($email){ return strlen($email) > 6 preg_match("/^[w-.]+@[w-]+(.w+)+$...

相关文章

PHP之友评论

今天推荐