|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #70263 filter_input_array 'add_empty' fails if query string absent
Submitted: 2015-08-13 22:24 UTC Modified: -
Avg. Score:4.7 ± 0.5
Reproduced:3 of 3 (100.0%)
Same Version:0 (0.0%)
Same OS:0 (0.0%)
From: mike dot whipps at littlevale dot co dot uk Assigned:
Status: Open Package: Filter related
PHP Version: 5.5.28 OS: Linux Fedora 20
Private report: No CVE-ID: None
Have you experienced this issue?
Rate the importance of this bug to you:

 [2015-08-13 22:24 UTC] mike dot whipps at littlevale dot co dot uk
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 = [

    echo '$_GET: <br>';

    $req = filter_input_array(INPUT_GET, $getFilters, true);
    echo '<hr>$req:<br>';

    echo '<hr>$reqGet<br>';
    $reqGet = filter_var_array($_GET, $getFilters, true);

Actual result:
Execute the above script with no query string gives this result:


array (size=0)




array (size=2)
  'id' => null
  'name' => null


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2019-11-01 13:22 UTC] vorbox+php at pp dot me
confirmed PHP7.4.0RC5 Windows 7 32.
PHP Copyright © 2001-2020 The PHP Group
All rights reserved.
Last updated: Thu Apr 09 20:01:23 2020 UTC