What potential pitfalls can arise when validating email addresses in PHP forms, as seen in the provided code snippet?

One potential pitfall when validating email addresses in PHP forms is using a basic regular expression that may not cover all valid email formats. To address this issue, it's recommended to use PHP's built-in filter_var function with the FILTER_VALIDATE_EMAIL filter, which provides a more robust validation method.

// Validate email address using filter_var
$email = $_POST['email'];

if (!filter_var($email, FILTER_VALIDATE_EMAIL)) {
    echo "Invalid email address";
} else {
    echo "Email address is valid";
}