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. |