最新消息:

PHP函数第11款:检测邮箱正确与否函数checkEmail

PHP扩展函数 杨红伟 4155浏览 0评论

一:函数简介

其实在前端就能检测邮箱这样的数据,但是有时候我们需要在后台检测。这款函数其实就是用正则表达式来匹配解决,就这么简单!

演示地址: http://www.ijquery.cn/phpfunction/checkEmail/demo1.php

下载地址: http://www.ijquery.cn/phpfunction/checkEmail/checkEmail.zip

二:函数应用

$emailor  = CheckEmail("403236160@qq.com") ? "正确的邮箱!" : "错误的邮箱";
echo $emailor;

三:函数代码

//邮箱格式检查
if ( ! function_exists('CheckEmail'))
{
    function CheckEmail($email)
    {
        if (!empty($email))
        {
            return preg_match('/^[a-z0-9]+([\+_\-\.]?[a-z0-9]+)*@([a-z0-9]+[\-]?[a-z0-9]+\.)+[a-z]{2,6}$/i', $email);
        }
        return FALSE;
    }
}

四:函数图片


Warning: Use of undefined constant PRC - assumed 'PRC' (this will throw an Error in a future version of PHP) in /www/wwwroot/www.ijquery.cn/wp-content/themes/d8-3.0/comments.php on line 17
发表我的评论
取消评论
表情

Hi,您需要填写昵称和邮箱!

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址