PHP Valid Email


/ Published in: PHP
Save to your folder(s)



Copy this code and paste it in your HTML
  1. error_reporting( E_ALL );
  2.  
  3. function is_valid_email( $email )
  4. {
  5. return preg_match( '/[.+a-zA-Z0-9_-]+@[a-zA-Z0-9-]+.[a-zA-Z]+/', $email );
  6. }
  7.  
  8. $emails = array( 'br0k3n',
  9. 'fred_dred@aol.com',
  10. 'fred-dred@aol.com',
  11. 'fred.dred@aol.com',
  12. 'fred+dred@aol.com' );
  13.  
  14. foreach( $emails as $email )
  15. {
  16. echo $email . ' is' . ( is_valid_email( $email ) ? '' : ' not' ) . " valid\n";
  17. }

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.