Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save lslucas/559181 to your computer and use it in GitHub Desktop.
Save lslucas/559181 to your computer and use it in GitHub Desktop.
<?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 - bad@email.com
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment