1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 | <?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"; } ?> |
欢迎光临 黑马程序员技术交流社区 (http://bbs.itheima.com/) | 黑马程序员IT技术论坛 X3.2 |