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实现通用的信用卡验证类

本文实例讲述了php实现通用的信用卡验证类。分享给大家供大家参考。 原文说明如下: Credit Card Validation Solution (PHP Edition) Vers...

php表单敏感字符过滤类

本文实例讲述了php表单敏感字符过滤类及其用法。分享给大家供大家参考。具体分析如下: 复制代码 代码如下: /** * 表单生成验证文件 */ $_form = new formH...

php Undefined index和Undefined variable的解决方法

$act=$_POST['act']; 用以上代码总是提示 Notice: Undefined index: act in F:\win...

PHP简单获取随机数的常用方法小结

本文实例讲述了PHP简单获取随机数的常用方法。分享给大家供大家参考,具体如下: 1.直接获取从min-max的数,例如1-20: $randnum = mt_rand(1, 20);...

php基础知识:类与对象(1)

php基础知识:类与对象(1)

类的定义:   以关键字 class 开头,后面跟着类名,可以是任何非 PHP 保留字的名字。后面跟着一对花括号,里面包含有类成员和方法的定义。伪变量$this可以在...