PHP Filter Functions

## PHP Basic

PHP HOME PHP Intro PHP Install PHP Syntax PHP Variables PHP Echo / Print PHP Data Types PHP String Functions PHP Constants PHP Operators PHP If...Else...Elseif PHP Switch PHP While Loops PHP For Loops PHP Functions PHP Arrays PHP Sorting Arrays PHP Superglobals

## PHP Forms

PHP Form Handling PHP Form Validation PHP Form Required PHP Form URL/E-mail PHP Form Complete

## PHP Advanced

PHP Arrays Multi PHP Date PHP Include PHP File PHP File Upload PHP Cookies PHP Sessions PHP E-mail PHP Secure E-mail PHP Error PHP Exception PHP Filter

## PHP Database

PHP MySQL Intro PHP MySQL Connect PHP CREATE DB/Table PHP INSERT INTO PHP SELECT PHP WHERE PHP ORDER BY PHP UPDATE PHP DELETE PHP ODBC

## PHP XML

XML Expat Parser XML DOM XML SimpleXML

## PHP and AJAX

AJAX Intro AJAX PHP AJAX Database AJAX XML AJAX Live Search AJAX RSS Reader AJAX Poll

## PHP Reference

PHP Array PHP Calendar PHP Date PHP Directory PHP Error PHP Filesystem PHP Filter PHP FTP PHP HTTP PHP Libxml PHP Mail PHP Math PHP Misc PHP MySQLi PHP SimpleXML PHP String PHP XML PHP Zip PHP Timezones

## PHP Quiz

PHP Quiz PHP Certificate

# PHP Filter Functions

« Previous
Next Chapter »

## PHP Filter Introduction

This PHP filters is used to validate and filter data coming from insecure sources, like user input.

## Installation

The filter functions are part of the PHP core. There is no installation needed to use these functions.

## PHP Filter Functions

PHP: indicates the earliest version of PHP that supports the function.

Function | Description | PHP
--- | --- | ---
filter_has_var() | Checks if a variable of a specified input type exist | 5
filter_id() | Returns the ID number of a specified filter | 5
filter_input() | Get input from outside the script and filter it | 5
filter_input_array() | Get multiple inputs from outside the script and filters them | 5
filter_list() | Returns an array of all supported filters | 5
filter_var_array() | Get multiple variables and filter them | 5
filter_var() | Get a variable and filter it | 5

## PHP Filters

ID Name | Description
--- | ---
FILTER_CALLBACK | Call a user-defined function to filter data
FILTER_SANITIZE_STRING | Strip tags, optionally strip or encode special characters
FILTER_SANITIZE_STRIPPED | Alias of "string" filter
FILTER_SANITIZE_ENCODED | URL-encode string, optionally strip or encode special characters
FILTER_SANITIZE_SPECIAL_CHARS | HTML-escape '"<>& and characters with ASCII value less than 32
FILTER_SANITIZE_EMAIL | Remove all characters, except letters, digits and !#$%&'*+-/=?^_`{|}~@.[]
FILTER_SANITIZE_URL | Remove all characters, except letters, digits and $-_.+!*'(),{}|\\^~[]`<>#%";/?:@&=
FILTER_SANITIZE_NUMBER_INT | Remove all characters, except digits and +-
FILTER_SANITIZE_NUMBER_FLOAT | Remove all characters, except digits, +- and optionally .,eE
FILTER_SANITIZE_MAGIC_QUOTES | Apply addslashes()
FILTER_UNSAFE_RAW | Do nothing, optionally strip or encode special characters
FILTER_VALIDATE_INT | Validate value as integer, optionally from the specified range
FILTER_VALIDATE_BOOLEAN | Return TRUE for "1", "true", "on" and "yes", FALSE for "0", "false", "off", "no", and "", NULL otherwise
FILTER_VALIDATE_FLOAT | Validate value as float
FILTER_VALIDATE_REGEXP | Validate value against regexp, a Perl-compatible regular expression
FILTER_VALIDATE_URL | Validate value as URL, optionally with required components
FILTER_VALIDATE_EMAIL | Validate value as e-mail
FILTER_VALIDATE_IP | Validate value as IP address, optionally only IPv4 or IPv6 or not from private or reserved ranges

« Previous
Next Chapter »

## Your suggestion:

Your E-mail (optional):

Page address:

Description:

Close [X]

## Thank You For Helping Us!

Your message has been sent to W3Schools.

Close [X]
Search w3schools.com:

## WEB HOSTING

Best Web Hosting UK Reseller Hosting Wow! $5 SSD Hosting

## WEB BUILDING

Download XML Editor
FREE Website BUILDER FREE Website Creator

## WEB RESOURCES

Web Statistics Web Validation

## SHARE THIS PAGE