Skip to content

Instantly share code, notes, and snippets.

@clarkeash
Created August 15, 2012 00:36
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 clarkeash/3354250 to your computer and use it in GitHub Desktop.
Save clarkeash/3354250 to your computer and use it in GitHub Desktop.
PHP function to validate an email address
<?php
function check_valid_email($email) {
$regex = '/^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})$/';
if (preg_match($regex, $email)) {
return true;
} else {
return false;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment