Validate Email Address using PHP

Below is a PHP function that validates an email address and returns the result as a boolean. This function uses the PHP built-in function filter_var and the filter FILTER_VALIDATE_EMAIL

<?php //php 7.0.8

function ValidateEmail($email)
  $email = '[email protected]';
  $isValid = filter_var($email, FILTER_VALIDATE_EMAIL);

  if ($isValid) 
   return true;
   return false;

Easy isn’t?

More PHP Snippets

Asha Shoukeir

About Asha shoukeir

Software Developer and System Administrator

View all posts by Asha shoukeir →