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

相关文章

Yii使用smsto短信接口的函数demo示例

本文实例讲述了Yii使用smsto短信接口的函数。分享给大家供大家参考,具体如下: public function smsto($telphone,$message) { /...

php实现的ping端口函数实例

本文实例讲述了php实现的ping端口函数。分享给大家供大家参考。 具体实现代码如下: 复制代码 代码如下: <?php /*  * @author &...

PHP制作用户注册系统

到目前为止,你已经了解了足够多的PHP了。该写个小程序练手了。 用户注册系统 写一个index.php页面,有用户名和密码表单,post提交到check.php,输出用户名和"用户名+密...

php number_format() 函数通过千位分组来格式化数字的实现代码

定义和用法number_format() 函数通过千位分组来格式化数字。 语法number_format(number,decimals,decimalpoint,separator)...

php获取ajax的headers方法与内容实例

1.前端页面 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org...