php 检查电子邮件函数(自写)

yipeiwu_com6年前PHP代码库

复制代码 代码如下:

function is_valid_email_address($email){
$qtext = '[^//x0d//x22//x5c//x80-//xff]';
$dtext = '[^//x0d//x5b-//x5d//x80-//xff]';
$atom = '[^//x00-//x20//x22//x28//x29//x2c//x2e//x3a-//x3c'.
'//x3e//x40//x5b-//x5d//x7f-//xff]+';
$quoted_pair = '//x5c[//x00-//x7f]';
$domain_literal = "//x5b($dtext|$quoted_pair)*//x5d";
$quoted_string = "//x22($qtext|$quoted_pair)*//x22";
$domain_ref = $atom;
$sub_domain = "($domain_ref|$domain_literal)";
$word = "($atom|$quoted_string)";
$domain = "$sub_domain(//x2e$sub_domain)*";
$local_part = "$word(//x2e$word)*";
$addr_spec = "$local_part//x40$domain";
return preg_match("!^$addr_spec$!", $email) ? 1 : 0;
}

相关文章

强烈声明: 不要使用(include/require)_once

关于使用include还是include_once(以下,都包含require_once), 这个讨论很长了, 结论也一直有, 就是尽量使用include, 而不是include_onc...

用PHP实现Ftp用户的在线管理的代码

领导要我策划一个网页设计大赛和Flash创作大赛,要求必须实现在线报名和上传作品。通过FreeBSD+Apache+PHP+Mysql+FTP我实现了该要求。 实现在线报名和上传作品的思...

PHP多人模块开发原理解析

PHP多人模块开发原理解析

作为世界上最“好”的语言,在web里占据着大概80%的份额,中小公司基本都说 lnmp 架构。当一个仓库开发人员大于1,20人的时候,每个人可能开发不同的模块和功能,用代码版本控制工具比...

深入PHP magic quotes的详解

深入PHP magic quotes的详解

特地查看了下手册,关于php  magic quotes,常见的几个设置如下,magic_quotes_gpc,magic_quotes_sybase,magic_quote_...

PHP实现图片的等比缩放和Logo水印功能示例

本文实例讲述了PHP实现图片的等比缩放和Logo水印功能。分享给大家供大家参考,具体如下: /** * 等比缩放函数(以保存的方式实现) * @param string $pic...