Definition and usage
The filter_var() function filters a variable specifying the filter.
Returns success of filtering data or FALSE on failure.
Grammar
filter_var(variable, filter, options)
variable: required. Specify variable filter: optional. Specifies the numbered filter to use. The default is FILTER_SANITIZE_STRING.
Check PHP filters for full possible reference filters. The filter number can be a number name (such as FILTER_VALIDATE_EMAIL) or an ID number (such as 274). Options: Optional. Specifies an associative array of flags/options or a single flag/option. Check out the various possible choices and flags for each filter
Let’s take a look at the filter_var example tutorial
if(!filter_var("someone@example....com", FILTER_VALIDATE_EMAIL)) { echo("E-mail is not valid"); } else { echo("E-mail is valid" ); } ?>
Output results.
E-mail is not valid