|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2011-07-03 17:53 UTC] zachary at stolertech dot com
Description:
------------
The FILTER_VALIDATE_EMAIL filter does not work as it should. If you include an IP address in your email address it filters as not valid.
The email we use for this experiment is php@[123.456.789.0], a fully valid email address. We also tested php@123.456.789.0 and its validates as FALSE.
Test script:
---------------
<?php
$emailwithip = "php@[123.456.789.0]";
if(!filter_var($emailwithip, FILTER_VALIDATE_EMAIL)) {
echo "EMAIL INVALID"; //Unexpected Result
} else {
echo "EMAIL VALID"; //Expected Correct Result
}
?>
Expected result:
----------------
TRUE
Actual result:
--------------
FALSE
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sat Nov 08 14:00:01 2025 UTC |
Thanks, I forgot that IPV4 only goes to 255. What if you were to use an IPV6 address? It doesn't seem to work. <?php $emailwithip = "php@[::1]"; if(!filter_var($emailwithip, FILTER_VALIDATE_EMAIL)) { echo "EMAIL INVALID"; //Unexpected Result } else { echo "EMAIL VALID"; //Expected Correct Result } ?>