PHP - Checking the format of an email address

October 2016

Here below you chould find sp techniques to determine if a variable contains a valid email address.

Using a filter

Using these type of fuction, you can check if email address is valid.
filter_var ()

if(filter_var($email, FILTER_VALIDATE_EMAIL)){
    //Email is good

Using regular expressions

With regular expressions, it is possible to check if an email address, obtained via a form, is valid.

Here is a function that checks if a string is only an e-mail address valide.function VerifierAdresseMail ($ address)

function VerifyMailAddress($address)
      return true;
     return false;


After getting the address a form:

  echo '<p>Your address is valid.</p>';
  echo '<p>Your address is not valid.</p>';

Related :

This document entitled « PHP - Checking the format of an email address » from CCM ( is made available under the Creative Commons license. You can copy, modify copies of this page, under the conditions stipulated by the license, as this note appears clearly.