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扩展Swoole实现实时异步任务队列示例

本文实例讲述了PHP扩展Swoole实现实时异步任务队列。分享给大家供大家参考,具体如下: 假如要发100封邮件,for循环100遍,用户直接揭竿而起,什么破网站! 但实际上,我们很可能...

PHP常见数学函数及BC高精度数学函数用法示例

本文实例讲述了PHP常见数学函数及BC高精度数学函数用法。分享给大家供大家参考,具体如下: 1. bcadd 任意精度数的相加 2. bcsub 任意精度数的减法 3. bcmul 乘法...

php获取从html表单传递数组的方法

本文实例讲述了php获取从html表单传递数组的方法。分享给大家供大家参考。具体如下: 将表单的各个元素的name都设置成同一个数组对象既可以以数组的方式传递表单值 html页面如下:...

php 调用远程url的六种方法小结

示例代码1: 用file_get_contents 以get方式获取内容 复制代码 代码如下:<?php $url='http://www.baidu.com/'; $html=f...

PHP中Static(静态)关键字功能与用法实例分析

本文实例讲述了PHP中Static(静态)关键字功能与用法。分享给大家供大家参考,具体如下: 1、什么是static? static 是C++中很常用的修饰符,它被用来控制变量的...