<?PHP$filters=array//define filtered arrays( "Name" =Array ( "Filter" =filter_sanitize_string), "Age" =Array ( The "filter" =>filter_validate_int,//option below is the filter options for Filter_validate_int, which can be used, "options" =Array//filter can be used with different filtering options ( "Min_range" =>1, "Max_range" =>120 ) ), "Email" =filter_validate_email); $result= Filter_input_array (Input_get,$filters); Right-side access filtered arrayif(!$result["Age"]){ Echo("Age must be between 1 and 120.") <br> ");}ElseIf(!$result["Email"]){ Echo("e-mail is not legal <br>");}Else{ Echo("Input correct");}?>
Ways to Customize filters:
<? PHP function convertspace ($string) { returnstr_replace$string $string = "www_fucktworld_com!" Echo filter_var ($string, filter_callback,array("Options" and "=" Convertspace "));? >
The result of the above code is as follows:
Www.fuckworld.com
The above example converts all "_" to ".":
Create a function that replaces "_" with "."
Call the Filter_var () function, whose arguments are the Filter_callback filter and the array that contains our functions
PHP's powerful filter filters user input