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截取中文字符串函数实例

本文实例讲述了php截取中文字符串函数。分享给大家供大家参考。具体实现方法如下: 复制代码 代码如下:<?php //中文字符串截取 function substr_zh(...

PHP常用排序算法实例小结【基本排序,冒泡排序,快速排序,插入排序】

php三种基础算法:冒泡,插入和快速排序法 $array = array(2,3,5,6,9,8,1); //冒泡排序思想,前后元素比较 function sort_bulldle...

PHP判断远程图片或文件是否存在的实现代码

最简单的方法就是用fopen(),看看文件能否打开,能打就文件当然就存在复制代码 代码如下:<?php$url = '//www.jb51.net/images/test.jpg'...

PHP5.2中PDO的简单使用方法

本文实例讲述了PHP5.2中PDO的简单使用方法。分享给大家供大家参考,具体如下: 一、PDO配置 1、确保PHP版本为5.2.5以上 2、在php.ini中找到Dynamic Exte...

简单的cookie计数器实现源码

复制代码 代码如下:<?php  if (!empty ($_COOKIE['example'] ))     &nbs...