Posted By

Tate on 12/30/08


Tagged

validation


Versions (?)

Who likes this?

1 person have marked this snippet as a favorite

justinscheetz


Check that a variable is a valid email address


 / Published in: PHP
 

Wordpress function

  1. function is_email($user_email) {
  2. $chars = "/^([a-z0-9+_]|\\-|\\.)+@(([a-z0-9_]|\\-)+\\.)+[a-z]{2,6}\$/i";
  3. if(strstr($user_email, '@') && strstr($user_email, '.')) {
  4. if (preg_match($chars, $user_email)) {
  5. return true;
  6. } else {
  7. return false;
  8. }
  9. } else {
  10. return false;
  11. }
  12. }

Report this snippet  

You need to login to post a comment.