Check Valid Email using filter_var


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



Copy this code and paste it in your HTML
  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. ?>

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

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.