Introduction to filter in php tutorial
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. |