What potential issues can arise when using regular expressions in PHP for email validation?

One potential issue when using regular expressions for email validation in PHP is that the expression may not cover all valid email formats, leading to false negatives. To solve this, you can use a more comprehensive regular expression pattern that accounts for a wider range of valid email formats.

$email = "example@email.com";

if (preg_match('/^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$/', $email)) {
    echo "Valid email address";
} else {
    echo "Invalid email address";
}