What are the potential risks of using regular expressions for email validation in PHP?

Using regular expressions for email validation in PHP can be risky because they may not cover all possible valid email formats and can lead to false positives or false negatives. It's better to use PHP's built-in filter_var function with the FILTER_VALIDATE_EMAIL filter for more accurate email validation.

$email = "test@example.com";

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