Posted By

koncept on 01/16/07


Tagged

email php function php5 validation


Versions (?)

Who likes this?

11 people have marked this snippet as a favorite

luman
basicmagic
almays
d4rk
vali29
hudge
nicolaspar
sindrom
mrjthethird
uilgenstein
ksnagra


PHP Email Validation


 / Published in: PHP
 

  1. <?php
  2. /**
  3.  * This function validates an email address, returning an integer
  4.  * depending on whether or not the email address provided is valid.
  5.  * A positive match will yield a result of 1, while a negative match
  6.  * will yield a result of 0. FALSE will be returned if an error occurred.
  7.  *
  8.  * @param string $email The email address to validate.
  9.  * @return integer The result of the validation.
  10.  */
  11. function isValidEmail( $email = null )
  12. {
  13. return preg_match( "/^
  14. [\d\w\/+!=#|$?%{^&}*`'~-]
  15. [\d\w\/\.+!=#|$?%{^&}*`'~-]*@
  16. [A-Z0-9]
  17. [A-Z0-9.-]{1,61}
  18. [A-Z0-9]\.
  19. [A-Z]{2,6}$/ix", $email );
  20. }
  21. ?>

Report this snippet  

Comments

RSS Icon Subscribe to comments
Posted By: koncept on October 5, 2008

UPDATE: See this one instead http://snipplr.com/view/8844/rfc822-compliant-email-address-validator/

You need to login to post a comment.