How to check whether an email is valid or not in php ?

Using filter_var function , we can check whether an email is valid or not valid with FILTER_VALIDATE_EMAIL filter.

if(filter_var(“sample@gmail.com”,FILTER_VALIDATE_EMAIL))
{

echo “valid”;

} else echo “not valid”;