Introduction to PHP Filter
PHP filters are used to validate and filter data from non-secure sources, such as user input.
Copy CodeThe code is as follows:
Remove HTML tags, or remove encoded special characters
Var_dump (Filter_var ("Chinese abc@#
BBB ", filter_sanitize_string));
url_encoded encoding, removing or encoding special characters
Var_dump (Filter_var ("http://Chinese AH", filter_sanitize_encoded));
The HTML escape character "" <>& and the ASCII value less than 32 characters.
Var_dump (Filter_var ("", Filter_sanitize_special_chars));
Remove all characters except letters, numbers, and!#$%& ' *+-/=?^_ ' {|} ~@. []
Var_dump (Filter_var ("as$&><", Filter_sanitize_email));
Delete all characters except letters, numbers, and $-_.+!* ' (), {}|\\^~[] ' <>#% ';/?:@&=
Var_dump (Filter_var ("k<>! ", Filter_sanitize_url));
Remove all characters except numbers and +-out
Var_dump (Filter_var ("123abc++", Filter_sanitize_number_int));
Remove all characters except numbers, +-and., EE.
Var_dump (Filter_var ("mm.,pp", filter_sanitize_number_float));
Application Addslashes
Var_dump (Filter_var ("aa//", filter_sanitize_magic_quotes));
Validates a value with an integer in the specified range
Var_dump (Filter_var (20,filter_validate_int,array ("Options" =>array ("Min_range" =>10, "Max_range" =>51)))) ;
Returns True if "1", "true", "on" and "Yes", and returns False if it is "0", "false", "off", "No", and "". Otherwise, NULL is returned.
Var_dump (Filter_var (1,filter_validate_boolean));
Validates the value with a floating-point number.
Var_dump (Filter_var (222,filter_validate_float));
Verify URL
Var_dump (Filter_var ("http://www.baidu.com", Filter_validate_url));
Verify Email
Var_dump (Filter_var ("abcd@123.com", Filter_validate_email));
Verify IP Address
Var_dump (Filter_var ("1.1.1.266", filter_validate_ip));
http://www.bkjia.com/PHPjc/695099.html www.bkjia.com true http://www.bkjia.com/PHPjc/695099.html techarticle PHP Filter Introduction PHP filters are used to validate and filter data from non-secure sources, such as user input. Copy the code code as follows://Remove HTML tag, or remove encoding special ...