The filter function in php verifies and filters user input data. PHPFilter introduction PHP filters are used to verify and filter data from non-secure sources (such as user input. Copy the code as follows: remove the html tag or the PHP Filter code.
PHP filters are used to verify and filter data from unsafe sources (such as user input.
The code is as follows:
// Remove html tags or encode special characters
Var_dump (filter_var ("Chinese ABC @#Script abc scriptBBB", FILTER_SANITIZE_STRING ));
// Url_encoded encoding, excluding or encoding special characters
Var_dump (filter_var ("http: // Chinese", FILTER_SANITIZE_ENCODED ));
// Html escape character "" <> & characters with ASCII values smaller than 32.
Var_dump (filter_var ("", FILTER_SANITIZE_SPECIAL_CHARS ));
// Delete 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 ));
// Delete all characters except numbers and +-
Var_dump (filter_var ("123ABC ++", FILTER_SANITIZE_NUMBER_INT ));
// Delete all characters except numbers, +-, and. and eE.
Var_dump (filter_var ("mm., pp", FILTER_SANITIZE_NUMBER_FLOAT ));
// Apply addslashes
Var_dump (filter_var ("aa //'' ", FILTER_SANITIZE_MAGIC_QUOTES ));
// Verify the value in an integer in the specified range
Var_dump (filter_var (20, FILTER_VALIDATE_INT, array ("options" => array ("min_range" => 10, "max_range" => 51 ))));
// 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.
Var_dump (filter_var (1, FILTER_VALIDATE_BOOLEAN ));
// Verify the value with a floating point number.
Var_dump (filter_var (222, FILTER_VALIDATE_FLOAT ));
// Verify the 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 the IP address
Var_dump (filter_var ("1.1.1.266", FILTER_VALIDATE_IP ));
Http://www.bkjia.com/PHPjc/695099.htmlwww.bkjia.comtruehttp://www.bkjia.com/PHPjc/695099.htmlTechArticlePHP Filter introduction PHP filters are used to validate and Filter data from unsafe sources, such as user input. The code is as follows: // remove the html tag, or remove the encoding special...