What considerations should be made when using filter_var with FILTER_VALIDATE_EMAIL in PHP to account for IDN and other limitations?

When using filter_var with FILTER_VALIDATE_EMAIL in PHP, it's important to consider that it may not fully support Internationalized Domain Names (IDN) and other limitations. To address this, you can use a more robust validation method, such as a regular expression or a dedicated library that supports IDN.

$email = "user@example.com";

if (filter_var($email, FILTER_VALIDATE_EMAIL)) {
    // Email is valid
} else {
    // Email is not valid
}