<?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");
}
?>
$email = "email@email.fr";
if (!filter_var($email, FILTER_VALIDATE_EMAIL)) {
$emailErr = "Email invalide";
}
//BE CAREFUL!!!
//NEVER VALIDATE A EMAIL WITH A NORMAL PREG MATCH
//I SAW THIS A LOT VALIDATING A EMAIL IS THE BEST TO SEND A EMAIL
//AND VERIFY
//BECAUSE SOMEONE MIGHT HAVE A RIGHT EMAIL THAT DOESNT WORK BECAUSE OF
//PREG MATCH