What are the advantages of using filter_var over eregi for email validation in PHP?
Using filter_var for email validation in PHP is preferred over eregi because filter_var is a more modern and reliable method for validating email addresses. eregi is deprecated and not recommended for use in newer PHP versions. filter_var provides a more secure and accurate way to validate email addresses according to the RFC standards.
$email = "example@example.com";
if (filter_var($email, FILTER_VALIDATE_EMAIL)) {
echo "Valid email address";
} else {
echo "Invalid email address";
}