Check if Email is Valid Format in PHP

By: Paypal August 4, 2025 PHP

Description

This snippet validates whether an email address is in the correct format using PHP’s built-in filter_var.

Code Snippet

$email = 'test@example.com';

if (filter_var($email, FILTER_VALIDATE_EMAIL)) {
    echo "Valid email!";
} else {
    echo "Invalid email.";
}

Discussion (0)