Skip to content

Instantly share code, notes, and snippets.

@devluis
Created December 29, 2013 20:07
Show Gist options
  • Save devluis/8174240 to your computer and use it in GitHub Desktop.
Save devluis/8174240 to your computer and use it in GitHub Desktop.
validate email with regular expression in PHP
<?php
$email = "[email protected]";
if(eregi("^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})$", $email)) {
echo "Valid email address.";
}
else {
echo "Invalid email address.";
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment