Posted By

sandrews_06 on 08/30/10


Tagged

email php validation


Versions (?)

Check Valid Email using filter_var


 / Published in: PHP
 

URL: http://www.devirtuoso.com/2010/08/quick-tip-validate-email-addresses-with-php/

  1. <?php
  2. //Bad Email...
  3. $badEmail = "bad@email";
  4.  
  5. //Run the email through an email validation filter.
  6. if( !filter_var($badEmail, FILTER_VALIDATE_EMAIL) ){
  7. echo "Email is no good.";
  8. }else{
  9. echo "Nice email.";
  10. }
  11.  
  12. //Result - Email is no good.
  13. ?>

Report this snippet  

You need to login to post a comment.