PHPFilter introduction PHP filters are used to verify and filter data from non-secure sources (such as user input. Installing the filter function is a core component of PHP. These functions can be used without installation. PHPFilter function PHP: indicates the earliest PHP version that supports this function. Function description
Introduction to PHP Filter
PHP filters are used to verify and filter data from unsafe sources (such as user input.
Install
The filter function is a core component of PHP. These functions can be used without installation.
PHP Filter function
PHP: indicates the earliest PHP version that supports this function.
| Function |
Description |
PHP |
| Filter_has_var () |
Check whether a variable of the specified input type exists. |
5 |
| Filter_id () |
Returns the ID of the specified filter. |
5 |
| Filter_input () |
Obtain and filter the input from outside the script. |
5 |
| Filter_input_array () |
Obtain multiple inputs from outside the script and filter them out. |
5 |
| Filter_list () |
Returns an array containing all the supported filters. |
5 |
| Filter_var_array () |
Obtain and filter multiple variables. |
5 |
| Filter_var () |
Obtain and filter a variable. |
5 |
PHP Filters
| ID |
Description |
| FILTER_CALLBACK |
You can call a user-defined function to filter data. |
| FILTER_SANITIZE_STRING |
Remove tags, remove or encode special characters. |
| FILTER_SANITIZE_STRIPPED |
The alias of the "string" filter. |
| FILTER_SANITIZE_ENCODED |
URL-encode string to remove or encode special characters. |
| FILTER_SANITIZE_SPECIAL_CHARS |
HTML escape character '"<> & characters with ASCII values smaller than 32. |
| FILTER_SANITIZE_EMAIL |
Delete all characters except letters, numbers, and! # $ % & '* +-/=? ^ _ '{| }~ @. [] |
| FILTER_SANITIZE_URL |
Delete all characters except letters, numbers, and $-_. +! * '(), {}|\\^ ~ [] '<> # % ";/? : @ & = |
| FILTER_SANITIZE_NUMBER_INT |
Delete all characters except numbers and +- |
| FILTER_SANITIZE_NUMBER_FLOAT |
Delete all characters except numbers, +-, and., eE. |
| FILTER_SANITIZE_MAGIC_QUOTES |
Apply addslashes (). |
| FILTER_UNSAFE_RAW |
Do not filter, remove, or encode special characters. |
| FILTER_VALIDATE_INT |
The value is verified by an integer in the specified range. |
| FILTER_VALIDATE_BOOLEAN |
If it is "1", "true", "on", and "yes", true is returned. if it is "0", "false", "off ", "no" and "", false is returned. Otherwise, NULL is returned. |
| FILTER_VALIDATE_FLOAT |
Verify the value with a floating point number. |
| FILTER_VALIDATE_REGEXP |
Verify the value based on regexp and Perl-compatible regular expressions. |
| FILTER_VALIDATE_URL |
Use the value as the URL for verification. |
| FILTER_VALIDATE_EMAIL |
Use the value as email for verification. |
| FILTER_VALIDATE_IP |
Use the value as the IP address for verification. |