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的CMS中展示文章类实例分析

本文实例讲述了基于php的CMS中展示文章类。分享给大家供大家参考。具体分析如下: <?php /***********************************...

php验证手机号码(支持归属地查询及编码为UTF8)

复制代码 代码如下: <?php // 手机号验证 function checkMobileValidity($mobilephone){ $exp = "/^13[0-9]{1}...

PHP 程序员也要学会使用“异常”

网站完全开放的特性,决定了网站比任何传统软件都更希望做到“系统看起来永远都是能够正常工作的”,所以采用正确的程序错误处理方式尤为重要。理论上来说,如果设计足够完美,开发人员足够谨慎,程序...

基于PHP Socket配置以及实例的详细介绍

基于PHP Socket配置以及实例的详细介绍

2个php测试文件server.php复制代码 代码如下:<?php     //phpinfo();//确保在连接客户端时不会超时set_...

PHP判断是否连接上网络的方法

本文实例讲述了PHP判断是否连接上网络的方法。分享给大家供大家参考。具体实现方法如下: 首先写个函数 function varify_url($url){ $check = @fo...