Php 5 Filter Functions

In PHP, filters plays an important role to validate and filter data that comes from an insecure sources, like user input, etc.

These are many Php 5 filter functions :

filter_has_var()

It checks whether a variable of a specified input type exist or not.

Syntax:

filter_has_var(type, variable)

Example:

Php 5 Filter Functions

filter_id()

It is used to return the filter ID of any specified filter name.

Syntax:

filter_id(filter_name)

Example:

Filter Functions

filter_input()

It is used to get an external variable like form input, etc. and then optionally filters it.

Syntax:

filter_input(type, variable, filter, options)

Example:

Filter input

filter_input_array()

It is used to get an external variables like form input, etc. and then optionally filters them. Basically, it is useful when we need to filter many values then we can use this function instead of calling filter_input() multiple times.

Syntax:

filter_input_array(type, definition, add_empty)

Example:

Filter Input Array

filter_list()

It will return the list of all the supported filters.

Syntax:

filter_list()

Example:

Filter List

filter_var_array()

It is used to get multiple variables and then filter them.

Syntax:

filter_var_array(array, args)

Example:

Filter var array

filter_var()

It is used filters a variable with any specified filter.

Syntax:

filter_var(var, filtername, options)

Example:

Filter var