Skip to content

Instantly share code, notes, and snippets.

@hilyjiang
Created May 7, 2013 07:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hilyjiang/5530740 to your computer and use it in GitHub Desktop.
Save hilyjiang/5530740 to your computer and use it in GitHub Desktop.
验证EMAIL是否合法的函数,CodeIgniter Helper
<?php
// 验证邮箱地址是否合法
if ( ! function_exists('verify_email'))
{
function verify_email($email)
{
$regex = "/^([\w\!\#$\%\&\'\*\+\-\/\=\?\^\`{\|\}\~]+\.)*[\w\!\#$\%\&\'\*\+\-\/\=\?\^\`{\|\}\~]+@((((([a-z0-9]{1}[a-z0-9\-]{0,62}[a-z0-9]{1})|[a-z0-9])\.)+[a-z]{2,6})|(\d{1,3}\.){3}\d{1,3}(\:\d{1,5})?)$/i";
return preg_match($regex, $email) === 1;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment