Last active
September 9, 2016 10:37
-
-
Save kenzo0107/49922bf85c73f5f85031ea4abf3aa7ce to your computer and use it in GitHub Desktop.
This file contains hidden or 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 | |
// http://www.tabimoba.net/entry/2014/02/08/154120#.V9JP2pOLS34 | |
// https://github.com/symfony/symfony/issues/18177 | |
// 検証フィルタのみのチェック | |
function checkEmail($email){ | |
return filter_var($email, FILTER_VALIDATE_EMAIL); | |
} | |
// よく見るバリデーションチェック | |
function checkEmailDefault($email) { | |
return (preg_match('/^[a-zA-Z0-9_\.@\+\?-]+$/i', $email)); | |
} | |
$emails = array( | |
'[email protected]' | |
,'[email protected]' | |
,'a"[email protected]' | |
,'a@[email protected]' | |
,'a#[email protected]' | |
,'[email protected]' | |
,'a%[email protected]' | |
,'a&[email protected]' | |
,'a`[email protected]' | |
,'a([email protected]' | |
,'a)[email protected]' | |
,'[email protected]' | |
,'[email protected]' | |
,'[email protected]' | |
,'a|[email protected]' | |
,'a\[email protected]' | |
,'a^[email protected]' | |
,'a:[email protected]' | |
,'a;[email protected]' | |
,'a*[email protected]' | |
,'[email protected]' | |
,'[email protected]' | |
,'a<[email protected]' | |
,'a>[email protected]' | |
,'a>[email protected]' | |
,'a,[email protected]' | |
,'a`[email protected]' | |
,'a[[email protected]' | |
,'a][email protected]' | |
,'a{[email protected]' | |
,'a}[email protected]' | |
,'a}[email protected]' | |
,'¥[email protected]' | |
,'[email protected]' | |
,'"[email protected]' | |
,'@[email protected]' | |
,'#[email protected]' | |
,'[email protected]' | |
,'%[email protected]' | |
,'&[email protected]' | |
,'([email protected]' | |
,')[email protected]' | |
,'[email protected]' | |
,'[email protected]' | |
,'|[email protected]' | |
,'\[email protected]' | |
,'^[email protected]' | |
,':[email protected]' | |
,';[email protected]' | |
,'*[email protected]' | |
,'[email protected]' | |
,'[email protected]' | |
,'<[email protected]' | |
,'>[email protected]' | |
,',[email protected]' | |
,'`[email protected]' | |
,'[[email protected]' | |
,'][email protected]' | |
,'{[email protected]' | |
,'}[email protected]' | |
,'[email protected]' | |
,'[email protected]' | |
,'[email protected]' | |
,'[email protected]' | |
,'abc@@vwx.yz' | |
,'[email protected]' | |
); | |
$ng_emails = array(); | |
$ok_emails = array(); | |
foreach ($emails as $email) { | |
if (checkEmail($email, true)) { | |
// echo '(^-^):'.$email."\n"; | |
$ok_emails[] = $email; | |
} else { | |
// echo '(>_<):'.$email."\n"; | |
$ng_emails[] = $email; | |
} | |
} | |
echo "\n[OK (^-^) EMAIL LIST]\n"; | |
if (!empty($ok_emails)) { | |
foreach ($ok_emails as $email) { | |
echo $email."\n"; | |
} | |
} | |
echo "\n[NG (>_<) EMAIL LIST]\n"; | |
if (!empty($ng_emails)) { | |
foreach ($ng_emails as $email) { | |
echo $email."\n"; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment