What are the potential pitfalls of using eregi() function in PHP for email validation?

The eregi() function is deprecated in PHP and should not be used for email validation as it is case-insensitive and may lead to security vulnerabilities. It is recommended to use filter_var() function with FILTER_VALIDATE_EMAIL filter for proper email validation in PHP.

$email = "example@example.com";

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