php 检查电子邮件函数(自写)

yipeiwu_com5年前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;
}

相关文章

Apache2 httpd.conf 中文版

给新手和我看的  #  # 基于 NCSA 服务的配置文件。  #  #这是Apache服务器主要配置文件。&nbs...

PHP正则匹配操作简单示例【preg_match_all应用】

本文实例讲述了PHP正则匹配操作。分享给大家供大家参考,具体如下: <?php $str = <<< EOT <a href="...

php下实现一个阿拉伯数字转中文数字的函数

如果要用于金额的转换,对小数部分的处理要做一下修改 <?php function ch_num($num,$mode=true) { $char =&...

PHP自动重命名文件实现方法

本文实例讲述了PHP自动重命名文件实现方法。分享给大家供大家参考。具体方法分析如下: PHP重命名文件名我们在实际开发过程中经常会使用到,比如用户上传文件或是一些缓存文件自动生成的功能我...

PHP获取网卡地址的代码

复制代码 代码如下:<?php     @exec("ipconfig /all",$array);  &nb...