PHP Filter Functions

Beginner
4 min read
Updated: Nov 2026
7 function guides
Function index

About This Index

This page is the PHP Filter Functions index for the tutorial track. Each row links to a full guide with syntax, examples, and FAQs.

Learn what the filter extension is and how to validate and sanitize input on /php/filter. Use this page when you need a specific helper such as filter_var(), filter_input(), or filter_var_array().

Beginner path.

Start with filter_var() and filter_input()—then browse the array helpers and the check and list functions.

How to Call a Filter Function

Filter helpers are global functions—pass a value (or an input type) and a FILTER_* constant:

PHP
$email = filter_var($input, FILTER_VALIDATE_EMAIL);

if ($email === false) {
    echo 'Invalid email';
}

// From a request source
$page = filter_input(INPUT_GET, 'page', FILTER_VALIDATE_INT);

PHP Filter Functions Table

All function guides in this PHP tutorial series (7 tutorials in 4 categories).

Check & list

3 functions

Check that an input variable exists and discover which filters PHP supports.

FunctionDescriptionTutorial
filter_has_var()Check if a variable of a specified input type exists.Try it
filter_id()Return the filter ID for a filter name.Try it
filter_list()Return a list of all supported filter names.Try it

Filter a value

1 function

Validate or sanitize a single value you already hold in a variable.

FunctionDescriptionTutorial
filter_var()Filter a variable with a specified filter.Try it

Filter input sources

1 function

Read one variable straight from GET, POST, cookies, server, or environment and filter it.

FunctionDescriptionTutorial
filter_input()Get a specific external variable by name and optionally filter it.Try it

Filter arrays

2 functions

Filter many values at once with a single definition, from an input source or from an array.

FunctionDescriptionTutorial
filter_input_array()Get external variables and optionally filter them.Try it
filter_var_array()Get multiple variables and optionally filter them.Try it

Frequently Asked Questions

PHP Filter functions validate and sanitize data. They work with FILTER_* constants to check emails, integers, URLs, and more, either on a value you hold (filter_var) or on a request source such as GET or POST (filter_input).
The Filter page teaches the ideas: validating vs sanitizing, filter_var vs filter_input, and the FILTER_* constants. This index lists every function tutorial so you can open filter_var(), filter_input(), and the rest.
For a value in a variable, call filter_var(). For form or query data, call filter_input(). When you need to filter a whole form at once, use filter_input_array() or filter_var_array().
Call filter_list() to get the names of every filter your PHP build supports, then pass a name to filter_id() to get its numeric ID for use with filter_var().
If you are new, read PHP Filter first. Then open filter_var() and filter_input() from the table below.

Start with filter_has_var()

Open the first guide—syntax, examples, and FAQs.

filter_has_var() tutorial →

About the author

Mari Selvan M P
Mari Selvan M P 🔗

Developer, cloud engineer, and technical writer

  • Experience 12 years building web and cloud systems
  • Focus Full Stack Development, AWS, and Developer Education

I write practical tutorials so students and working developers can learn by doing—from databases and APIs to deployment on AWS.

15 people found this page helpful