Page 1 of 1

PHP Filter

PostPosted: Wed May 20, 2009 11:00 pm
by jay
A PHP filter is used to validate and filter data coming from insecure sources. For example to validate whether the input is email address or integer, it's easy to validate using inbuilt PHP functions like filter_var($email, FILTER_VALIDATE_EMAIL) to server side validate email address and filter_var($int, FILTER_VALIDATE_INT) to validate whether the input is integer.

To test, validate and filter user input or custom data is an important part of any web application.

The PHP filter extension is designed to make data filtering easier and quicker.

Almost all web applications depend on external input. Usually this comes from a user or another application (like a web service). By using filters you can be sure your application gets the correct input type.

filter_var() - Filters a single variable with a specified filter
filter_var_array() - Filter several variables with the same or different filters
filter_input - Get one input variable and filter it
filter_input_array - Get several input variables and filter them with the same or different filters

For more details -