Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • 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 - [email protected]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment