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 实现explort() 功能的详解

复制代码 代码如下:<?php/** * PHP 实现explort() 功能的详解 */$str = ',1,2,3,4,321321,aaa,bbb';fu...

php使用cookie保存用户登录的用户名实例

本文实例讲述了php使用cookie保存用户登录的用户名的方法。分享给大家供大家参考。具体实现方法如下: 用户登录文件:login.php 复制代码 代码如下:<html>...

php fread函数使用方法总结

php fread函数用于读取文件(可安全用于二进制文件),其语法是fread(file,length),参数file必需,指规定要读取打开文件,length 必需,指规定要读取的最大字...

php判断GIF图片是否为动画的方法

本文介绍了PHP判断GIF图片是动画的方法,具体步骤如下: 首先,gif动画是gif89格式的,发现文件开头是gif89。但是很多透明图片也是用的gif89格式, GOOGLE到的:可以...

php计划任务之ignore_user_abort函数实现方法

本文实例讲述了php计划任务之ignore_user_abort函数实现方法。分享给大家供大家参考。具体分析如下: PHP 不会检测到用户是否已断开连接,直到尝试向客户机发送信息为止,简...