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

相关文章

屏蔽机器人从你的网站搜取email地址的php代码

垃圾邮件很烦人,下面贴一种能够自动屏蔽机器人从你的网站搜集email地址的方法。 复制代码 代码如下: function security_remove_emails($content)...

PHP SPL使用方法和他的威力

SPL,PHP 标准库(Standard PHP Library) ,此从 PHP 5.0 起内置的组件和接口,并且从 PHP5.3 已逐渐的成熟。SPL 其实在所有的 PHP5 开发环...

php str_pad 函数用法简介

语法 str_pad(string,length,pad_string,pad_type) 参数 描述 string 必需。规定要填充的字符串。 length 必需。规定新字符串的长度。...

PHP 命令行参数详解及应用

复制代码 代码如下:# 不带参数的执行格式 php安装目录/bin/php scriptname.php # 带参数的执行格式 php安装目录/bin/php scriptname.ph...

解决ThinkPHP下使用上传插件Uploadify浏览器firefox报302错误的方法

最近用ThinkPHP开发一个项目,集成了批量上传文件插件Uploadify,在谷歌Chrome和IE下都能正常上传,只有火狐下提示这个错误,网上找了很多解决办法,基本都说flash在f...