I use the filter_var
PHP function to validate email address when a user signs up to my site.
I use this code from the post:
$email = filter_var($_POST['email'], FILTER_VALIDATE_EMAIL);
then later I do:
if(!$email) {
// return to the form
}
else {
// send registration info
}
now when I var_dump($email)
, I get the output:
string(23) "user."name"@example.com"
I would like to know why this does not return false. I think the double quotes are not acceptable, so why does PHP say it’s valid?
It is a valid email address :
A quoted string may exist as a dot separated entity within the local-part or it may exist when the outermost quotes are the outermost chars of the local-part (e.g. abc."defghi".xyz@example.com or "abcdefghixyz"@example.com are allowed. abc"defghi"xyz@example.com is not; neither is abc\"def\"ghi@example.com).