Home > php教程 > php手册 > php 邮箱,网址,手机号码合法性正则

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

WBOY
Release: 2016-05-25 16:55:42
Original
962 people have browsed it
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);
 }



永久链接:

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

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 Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template