Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save IftiMahmud/c1a16e45fb94336fcd2d to your computer and use it in GitHub Desktop.
Save IftiMahmud/c1a16e45fb94336fcd2d 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