Home>Article>Backend Development> Use php to verify whether the email format is correct
Verifying whether the email format is correct can be achieved through the filter_var function.
Function introduction:
filter_var() function filters a variable through the specified filter.
Syntax:
filter_var(variable, filter, options)
Parameter introduction:
variable, (required) specifies the variable to be filtered.
filter, (optional) Specifies the ID of the filter to use. The default is FILTER_SANITIZE_STRING.
options, (optional) Specifies an associative array containing flags/options or a single flag/option. Check the possible flags and options for each filter.
(Free learning video tutorial sharing:php video tutorial)
The verification method is as follows:
Here we created a check_email method , used to determine whether the email is qualified. Returns true if qualified, false otherwise.
The output is as follows:
true falseRecommended related article tutorials:php tutorial
The above is the detailed content of Use php to verify whether the email format is correct. For more information, please follow other related articles on the PHP Chinese website!