Easy Tutorial
❮ Func Cal Cal From Jd Func Array Change Key Case ❯

PHP Filter Functions


Introduction to PHP Filter

PHP filters are used to validate and sanitize data coming from insecure sources, such as user input.


Installation

The Filter functions are part of the PHP core. These functions are available without the need for installation.


PHP Filter Functions

PHP: Indicates the earliest PHP version that supports the function.

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

PHP Filters

ID Name Description
FILTER_CALLBACK Calls a user-defined function to filter data.
FILTER_SANITIZE_STRING Removes tags and optionally removes or encodes special characters.
FILTER_SANITIZE_STRIPPED Alias of the "string" filter.
FILTER_SANITIZE_ENCODED URL-encodes string, optionally removes or encodes special characters.
FILTER_SANITIZE_SPECIAL_CHARS HTML-escapes characters '"<>& and characters with ASCII value less than 32.
FILTER_SANITIZE_EMAIL Removes all characters except letters, digits, and !#$%&'*+-/=?^_`{ }~@.[]
FILTER_SANITIZE_URL Removes all characters except letters, digits, and $-_.+!*'(),{} \^~[]`<>#%";/?:@&=
FILTER_SANITIZE_NUMBER_INT Removes all characters except digits and +-
FILTER_SANITIZE_NUMBER_FLOAT Removes all characters except digits, +- and optionally .,eE
FILTER_SANITIZE_MAGIC_QUOTES Applies addslashes().
FILTER_UNSAFE_RAW Does no filtering, optionally removes or encodes special characters.
FILTER_VALIDATE_INT Validates value as an integer.
FILTER_VALIDATE_BOOLEAN Validates value as a boolean. Returns TRUE for "1", "true", "on" and "yes". Returns FALSE for "0", "false", "off", "no", and "". Otherwise returns NULL.
FILTER_VALIDATE_FLOAT Validates value as a float.
FILTER_VALIDATE_REGEXP Validates the value based on a Perl-compatible regular expression (regexp).
FILTER_VALIDATE_URL Validates the value as a URL.
FILTER_VALIDATE_EMAIL Validates the value as an e-mail address.
FILTER_VALIDATE_IP Validates the value as an IP address, limited to IPv4 or IPv6 or not from private or reserved ranges.
❮ Func Cal Cal From Jd Func Array Change Key Case ❯