<?php
header("Content-type: text/html; charset=utf-8");
$char_br="<br/>";
$str="QWERTYUIOPASDFGHJKLZXCVBNM1234567890qwertyuiopasdfghjklzxcvbnm";
$num=rand(5,20);
$random_test_value=substr(str_shuffle($str),rand(5,strlen($str)),$num);
$args=array(
"id" =>array('filter' => FILTER_VALIDATE_INT,
'options'=> array('min_range' => 1, 'max_range' => 10)
),
"missing"=>FILTER_SANITIZE_ENCODED,
"searched"=>FILTER_SANITIZE_ENCODED
);
$vars=filter_input_array(INPUT_GET,$args);
echo "<a href='?searched=$random_test_value&id=$num'>Search again.</a>$char_br";
if(filter_has_var(INPUT_GET,"searched")){
$search_html = $vars["searched"];
echo "You have searched for $search_html.$char_br";
}else{
echo "You searched nothing$char_br";
}
var_dump($vars);
$options=array(
'options'=>array(
'default' => 5,
'min_range' => 1,
'max_range' => 10
),
'flags' => FILTER_FLAG_ALLOW_OCTAL,
);
echo "id filtered by filter_var is:".filter_var($vars["id"],FILTER_VALIDATE_INT,$options)."$char_br";
echo "invoke filter_var_array filter agagin:$char_br";
var_dump(filter_var_array(filter_input_array(INPUT_GET),$args));
echo "支持的过滤器:$char_br id=>name $char_br";
foreach(filter_list() as $v){
echo filter_id($v),"=>$v$char_br";
}
?>