Home>Article>Backend Development> Use php to verify whether the email format is correct

Use php to verify whether the email format is correct

王林
王林 forward
2020-01-20 17:01:24 3996browse

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 false

Recommended 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!

Statement:
This article is reproduced at:jb51.net. If there is any infringement, please contact admin@php.cn delete