What are best practices for handling email addresses with special characters like "-" in PHP?

When handling email addresses with special characters like "-", it is important to properly sanitize and validate the input to ensure it is a valid email address format. One way to handle this is by using PHP's filter_var function with the FILTER_VALIDATE_EMAIL filter. This will validate the email address and ensure it meets the required format standards.

$email = "example-email@example.com";

if (filter_var($email, FILTER_VALIDATE_EMAIL)) {
    echo "Email address is valid.";
} else {
    echo "Email address is not valid.";
}