Forked from lslucas/Quick Tip: Validate Email Addresses with PHP
Last active
August 29, 2015 14:09
-
-
Save IftiMahmud/c1a16e45fb94336fcd2d to your computer and use it in GitHub Desktop.
This file contains 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 | |
//Bad Email... | |
$badEmail = "bad@email"; | |
//Run the email through an email validation filter. | |
if( !filter_var($badEmail, FILTER_VALIDATE_EMAIL) ){ | |
echo "Email is no good."; | |
}else{ | |
echo "Nice email."; | |
} | |
//Result - Email is no good. | |
##################### | |
//Crappy email. | |
$var="bad%%@em\#ail.com"; | |
//Runs email through a sanitize filter | |
print filter_var($var, FILTER_SANITIZE_EMAIL); | |
//Result - [email protected] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment