Skip to content

PHP code snippet – How to validate an email field ?

<?php
   $email = "pattrick@tutorialspoint.com";
   // Validate email
   if (filter_var($email, FILTER_VALIDATE_EMAIL)) {
      echo("$email is a valid email address");
   }
   else{
      echo("$email is not a valid email address");
   }
?>
See also  Python code snippet - How to add to a list ?

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.