I have use ereg to validate email address. But it gives an error.
return ereg("^[a-zA-Z0-9]+[a-zA-Z0-9_-]+@[a-zA-Z0-9]+[a-zA-Z0-9.-]+[a-zA-Z0-9]+.[a-z]{2,4}$", $email);
Deprecated: Function ereg() is deprecated
PHP5 does not support ereg function.so the alternative way is to use the
return ereg("^[a-zA-Z0-9]+[a-zA-Z0-9_-]+@[a-zA-Z0-9]+[a-zA-Z0-9.-]+[a-zA-Z0-9]+.[a-z]{2,4}$", $email);
Deprecated: Function ereg() is deprecated
PHP5 does not support ereg function.so the alternative way is to use the
filter_var()
function, which gives you a lot of handy validation and sanitization options.filter_var($email, FILTER_VALIDATE_EMAIL)
If you don't want to change your code that relied on your function, just do:
function isValidEmail($email){
return filter_var($email, FILTER_VALIDATE_EMAIL);
}
No comments:
Post a Comment