|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2019-11-01 13:22 UTC] vorbox+php at pp dot me
[2020-04-11 13:50 UTC] cmb@php.net
-Status: Open
+Status: Not a bug
-Assigned To:
+Assigned To: cmb
[2020-04-11 13:50 UTC] cmb@php.net
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sun Nov 16 17:00:02 2025 UTC |
Description: ------------ filter_input_array(INPUT_GET, $filters, true) does not add empty fields to the output array if the query string is absent. It does add them correctly if even one parameter appears. Note that filter_var_array($_GET, $filters, true) does add the empty fields correctly. Test script: --------------- $getFilters = [ 'id'=>['filter'=>FILTER_VALIDATE_INT, 'flags'=>FILTER_REQUIRE_SCALAR, 'options'=>['min_range'=>1] ], 'name'=>FILTER_UNSAFE_RAW ]; echo '$_GET: <br>'; var_dump($_GET); $req = filter_input_array(INPUT_GET, $getFilters, true); echo '<hr>$req:<br>'; var_dump($req); echo '<hr>$reqGet<br>'; $reqGet = filter_var_array($_GET, $getFilters, true); var_dump($reqGet); Actual result: -------------- Execute the above script with no query string gives this result: $_GET: array (size=0) empty $req: null $reqGet array (size=2) 'id' => null 'name' => null