What are some best practices for handling and manipulating email addresses in PHP, especially when dealing with different top-level domains?

When handling and manipulating email addresses in PHP, especially when dealing with different top-level domains, it is important to validate the email address format and ensure that it follows the rules set by the Internet Engineering Task Force (IETF) standards. One way to handle different top-level domains is to use PHP's built-in filter_var function with the FILTER_VALIDATE_EMAIL filter. This function will validate the email address based on RFC 822 and RFC 5322 standards.

$email = "example@example.com";

if (filter_var($email, FILTER_VALIDATE_EMAIL)) {
    echo "Valid email address";
} else {
    echo "Invalid email address";
}