Most of web applications accepts user credentials and one of the required fields is the email address. Once the form is submitted, it is a good practice to always check if the supplied email is a valid email or not, and throw an error message so the user will know that the supplied email is incorrect.

This code snippet will show you how to handle email validation.

if( filter_var('emailaddress', FILTER_VALIDATE_EMAIL) === false ) {
    echo 'This is not a valid email';

Or, by using it in a function

function is_email($str) {
    if( filter_var($str, FILTER_VALIDATE_EMAIL) === false ) {
        return false;
    return true;

if(is_email('')) {
    echo 'This is a valid email address';