note 118591 added to filter.filters.validate
| From: | sebastian dot piskorski at gmail dot com | Date: | Tue, 05 Jan 2016 12:48:29 +0000 |
| Subject: | note 118591 added to filter.filters.validate | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-204593@lists.php.net to get a copy of this message | ||
FILTER_VALIDATE_EMAIL not only doesn't support whitespace folding and comments. It only checks
Addr-spec part of email address. Otherwise it should mark such address as valid: 'Test Example
<test@example.com>' because it is valid according to RFC 822.
Also address "test@localhost" should be valid. Which is mentioned in another note.
You can test it with this code:
<?php
$emails = array(
'Test Example <test@example.com>',
'test@localhost',
'test@localhost.com'
);
foreach ($emails as $email) {
echo (filter_var($email, FILTER_VALIDATE_EMAIL)) ?
"[+] Email '$email' is valid\n" :
"[-] Email '$email' is NOT valid\n";
}
?>
Output for PHP 5.3.21 - 7.0.1 :
[-] Email 'Test Example <test@example.com>' is NOT valid
[-] Email 'test@localhost' is NOT valid
[+] Email 'test@localhost.com' is valid
----
Server IP: 72.52.91.14
Probable Submitter: 188.33.214.243
----
Manual Page -- http://php.net/manual/en/filter.filters.validate.php
Edit -- https://master.php.net/note/edit/118591
Del: integrated -- https://master.php.net/note/delete/118591/integrated
Del: useless -- https://master.php.net/note/delete/118591/useless
Del: bad code -- https://master.php.net/note/delete/118591/bad+code
Del: spam -- https://master.php.net/note/delete/118591/spam
Del: non-english -- https://master.php.net/note/delete/118591/non-english
Del: in docs -- https://master.php.net/note/delete/118591/in+docs
Del: other reasons-- https://master.php.net/note/delete/118591
Reject -- https://master.php.net/note/reject/118591
Search -- https://master.php.net/manage/user-notes.php