PHP filter_var() Function

The filter_var() function filters a variable with the specified filter.filter_var — Filters a variable with a specified filter.Returns the filtered data, or FALSE if the filter fails.

mixed filter_var ( mixed $variable [, int $filter = FILTER_DEFAULT [, mixed $options ]] )

Example -

The above example will output : -

string(15) "bob@example.com"
bool(false)

ParameterDescription
variableValue to filter. Note that scalar values are converted to string internally before they are filtered.
filternameOptional. Specifies the ID or name of the filter to use. Default is FILTER_DEFAULT, which results in no filtering
optionsOptional. Specifies one or more flags/options to use. Check each filter for possible options and flags