What are the potential pitfalls of using the ereg function in PHP for email validation?
The ereg function is deprecated in PHP and should not be used for email validation. Instead, it is recommended to use the filter_var function with the FILTER_VALIDATE_EMAIL flag to properly validate email addresses.
$email = "example@example.com";
if(filter_var($email, FILTER_VALIDATE_EMAIL)) {
echo "Valid email address";
} else {
echo "Invalid email address";
}
Related questions
-
unlink return value debugging
-
preg_quote preg_replace string replacements
-
$_GET variables security vulnerabilities data integrity