What are the potential pitfalls of using regular expressions for email validation in PHP?
Using regular expressions for email validation in PHP can be error-prone and may not cover all possible valid email formats. It is better to use PHP's built-in filter_var function with the FILTER_VALIDATE_EMAIL flag for more accurate validation.
$email = "example@example.com";
if (filter_var($email, FILTER_VALIDATE_EMAIL)) {
echo "Valid email address";
} else {
echo "Invalid email address";
}