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

相关文章

Discuz 6.0+ 批量注册用户名

1.将adduser.php复制到discuz根目录下; /--adduser.php内容如下--/ <? php require_once './include/common.i...

php实现基于pdo的事务处理方法示例

本文实例讲述了php实现基于pdo的事务处理方法。分享给大家供大家参考,具体如下: 实例1: try {} catch () {} 形式 <?php $dsn = 'm...

PHP计数器的实现代码

复制代码 代码如下:<?php/*使用文本文件记录数据的简单实现*/$counter=1;if(file_exists("mycounter.txt")){$fp=fopen("m...

PHP、Nginx、Apache中禁止网页被iframe引用的方法

可以使用php或nginx等添加X-Frame-Options header来控制frame权限X-Frame-Options有三个可选的值: DENY:浏览器拒绝当前页面加载任何Fra...

php设置静态内容缓存时间的方法

本文实例讲述了php设置静态内容缓存时间的方法。分享给大家供大家参考。具体方法分析如下: 在利用百度工具作一个小测试时提示我们需要设置静态内容缓存时间了,我自己没有服务器权限操作,只能从...