Skip to content

Instantly share code, notes, and snippets.

@InFog
Created January 15, 2018 14:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save InFog/e3bcd7f0122744e00fddf5040eaa11e1 to your computer and use it in GitHub Desktop.
Save InFog/e3bcd7f0122744e00fddf5040eaa11e1 to your computer and use it in GitHub Desktop.
Filter email in PHP
<?php
$validInput = "email@mail.com";
$invalidInput = "\"'/><script>alert(1)</script>";
echo "Valid: ";
echo filter_var($validInput, FILTER_VALIDATE_EMAIL);
echo PHP_EOL;
echo "Invalid: ";
echo filter_var($invalidInput, FILTER_VALIDATE_EMAIL);
echo PHP_EOL;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment