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

yipeiwu_com5年前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中大于2038年时间戳的问题处理方案

PHP有效的时间戳典型范围是格林威治时间 1901 年 12 月 13 日 20:45:54    到 2038 年 1 月 19 日 03:14:07。(...

php准确计算复活节日期的方法

本文实例讲述了php准确计算复活节日期的方法。分享给大家供大家参考。具体如下: <?PHP function isLeapYear( $nYEAR ) { if(((...

PHP应用跨时区功能的实现方法

PHP中要实现一个跨时区的应用,也就是不同时区登录的用户需要看到自己时区的时间,同时也要能够进行时区的切换。 这里的思路是,系统中所有存储的时间都是GMT(UTC)时间,用户登录时,根据...

php接口隔离原则实例分析

本文实例讲述了php接口隔离原则。分享给大家供大家参考,具体如下: 使用多个专门的接口比使用单一的总接口要好。 一个类对另外一个类的依赖性应当是建立在最小的接口上的。 一个接口代表一个角...

Eclipse中php插件安装及Xdebug配置的使用详解

Eclipse中php插件安装及Xdebug配置的使用详解

由于在android开发团队,又迷上了android自动化测试,所有一直使用Eclipse做为开发工具。以前使用Zend Studio 9.0.1做为PHP的开发工具,现在放弃使用Zen...