Created
May 21, 2014 20:38
-
-
Save lucien144/7439c2f939e620f9b1bc to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function isEmail($value) | |
{ | |
$atom = "[-a-z0-9!#$%&'*+/=?^_`{|}~]"; // RFC 5322 unquoted characters in local-part | |
$localPart = "(?:\"(?:[ !\\x23-\\x5B\\x5D-\\x7E]*|\\\\[ -~])+\"|$atom+(?:\\.$atom+)*)"; // quoted or unquoted | |
$alpha = "a-z\x80-\xFF"; // superset of IDN | |
$domain = "[0-9$alpha](?:[-0-9$alpha]{0,61}[0-9$alpha])?"; // RFC 1034 one domain component | |
$topDomain = "[$alpha](?:[-0-9$alpha]{0,17}[$alpha])?"; | |
return (bool) preg_match("(^$localPart@(?:$domain\\.)+$topDomain\\z)i", $value); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment