What are some best practices for checking and validating email addresses in PHP, considering special characters like " and '?

When checking and validating email addresses in PHP, it is important to consider special characters like " and '. One way to handle this is to use PHP's filter_var function with the FILTER_VALIDATE_EMAIL filter, which will validate the email address according to RFC 822. This function will properly handle special characters in email addresses.

$email = 'test@example.com';
if (filter_var($email, FILTER_VALIDATE_EMAIL)) {
    echo "Valid email address";
} else {
    echo "Invalid email address";
}