这听起来很奇怪,但我已经使用这个功能很长一段时间了,而且“突然间,从一天到另一天”它不再以正确的方式过滤某些地址。但是,我不明白为什么......
function validate_email($email)
{
/*
(Name) Letters, Numbers, Dots, Hyphens and Underscores
(@ sign)
(Domain) (with possible subdomain(s) ).
Contains only letters, numbers, dots and hyphens (up to 255 characters)
(. sign)
(Extension) Letters only (up to 10 (can be increased in the future) characters)
*/
$regex = '/([a-z0-9_.-]+)'. # name
'@'. # at
'([a-z0-9.-]+){2,255}'. # domain & possibly subdomains
'.'. # period
'([a-z]+){2,10}/i'; # domain extension
if($email == '') {
return false;
}
else {
$eregi = preg_replace($regex, '', $email);
}
return empty($eregi) ? true : false;
}
例如,“some@gmail”将显示为正确等,因此似乎 tld 发生了某事 - 有人能告诉我为什么吗?
非常感谢您!