ThinkChat2.0新版上线,更智能更精彩,支持会话、画图、阅读、搜索等,送10W Token,即刻开启你的AI之旅 广告
[TOC] ## 实例 ## 基础实例 ``` // curl -X POST -d "product_id=libgd<script>&component=10&versions=2.0.33&testscalar[]=2&testscalar[]=23&testscalar[]=10&testarray=2" http://127.0.0.1:8010/test.php //$_POST = [ // 'product_id' => 'libgd<script>', // 'component' => '10', // 'versions' => '2.0.33', // 'testscalar' => ['2', '23', '10', '12'], // 'testarray' => '2', //]; $args = [ 'product_id' => FILTER_SANITIZE_ENCODED, 'component' => [ 'filter' => FILTER_VALIDATE_INT, 'flags' => FILTER_REQUIRE_SCALAR, 'options' => [ 'min_range' => 1, 'max_range' => 10 ] ], 'versions' => FILTER_SANITIZE_ENCODED, 'doesnotexist' => [ "filter" => FILTER_VALIDATE_INT, ], 'testscalar' => [ 'filter' => FILTER_VALIDATE_INT, 'flags' => FILTER_REQUIRE_ARRAY, ], 'testarray' => [ 'filter' => FILTER_VALIDATE_INT, 'flags' => FILTER_REQUIRE_ARRAY, ] ]; $myinputs = filter_input_array(INPUT_POST, $args); print_r($myinputs); //Array //( // [product_id] => libgd%3Cscript%3E // [component] => 10 // [versions] => 2.0.33 // [doesnotexist] =>NULL // [testscalar] => Array // ( // [0] => 2 // [1] => 23 // [2] => 10 // ) // // [testarray] => //) ```