Menu
Samaritan's Purse

FILTER_VAR

Filters a variable with a specified filter

SYNTAX

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

PARAMETERS

variable

Value to filter. Note that scalar values are converted to string internally before they are filtered.

filter

The ID of the filter to apply. The Types of filters manual page lists the available filters.

If omitted, FILTER_DEFAULT will be used, which is equivalent to FILTER_UNSAFE_RAW. This will result in no filtering taking place by default.

options

Associative array of options or bitwise disjunction of flags. If filter accepts options, flags can be provided in "flags" field of array. For the "callback" filter, callable type should be passed. The callback must accept one argument, the value to be filtered, and return the value after filtering/sanitizing it.

RETURN

Returns the filtered data, or FALSE if the filter fails.

EXAMPLES

VARIABLE

osbo.com

FILTER

https://osbo.com

OPTIONS

https://osbo.com/path?query

1

493

2

NULL

3

NULL

4

myvariable

PHP