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;
}

相关文章

一个简单且很好用的php分页类

复制代码 代码如下:class Page {    // 分页栏每页显示的页数    public $rollPage = 6...

php字符串比较函数用法小结(strcmp,strcasecmp,strnatcmp及strnatcasecmp)

本文实例分析了php字符串比较函数用法。分享给大家供大家参考,具体如下: 直接比较字符串是否完全一致,可以使用"=="来进行,但是有时候可能需要进行更加复杂的字符串比较,如部分匹配等....

Php 构造函数construct的前下划线是双的_

定义和用法 __construct() 函数创建一个新的 SimpleXMLElement 对象。 如果成功,则该函数返回一个对象。如果失败,则返回 false。 语法__constr...

php根据命令行参数生成配置文件详解

像npm, composer等工具,在开始使用的使用,都需要初始化项目,生成一个项目的配置文件。这种功能的原理是怎么实现的呢? 比如: D:\>npm init --yes W...

解析php中memcache的应用

所需环境:php 5.3.3apache 2.2.7mysql 5.5.8相关文档下载:点击下载解压Memcached_1.2.5文档,cmd下执行memcached.exe -d -i...