|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Doc Bug #42608 Example #660 (filter_input_array) is wrong
Submitted: 2007-09-10 11:04 UTC Modified: 2018-05-05 16:25 UTC
Avg. Score:4.3 ± 1.0
Reproduced:17 of 18 (94.4%)
Same Version:7 (41.2%)
Same OS:7 (41.2%)
From: phpbugs dot 20 dot zsh at spamgourmet dot com Assigned: cmb (profile)
Status: Closed Package: Filter related
PHP Version: 5.2.4 OS: Irrelevant
Private report: No CVE-ID: None
View Add Comment Developer Edit
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please !
Your email address:
Solve the problem:
27 + 3 = ?
Subscribe to this entry?

 [2007-09-10 11:04 UTC] phpbugs dot 20 dot zsh at spamgourmet dot com
The example will not output the array shown below the example code -- any undefined variable will cause filter_input_array() to return (so the output would be "NULL").

You'll notice I've classified this as a change request rather than a documentation problem, for the expected (and described ("Return Values")) behavior in example #660 makes WAY more sense.

Reproduce code:


consistent_filter_input_array (last revision 2012-02-27 14:38 UTC by

Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2009-10-08 03:02 UTC] ChadFulton at gmail dot com
Although this is a very old bug, it seems to me that the poster is 
incorrect; I suspect the problem is that the poster attempted to set the 
$_POST array during runtime (e.g. $_POST = array( ... ); ), and 
filter_input_array does not allow runtime modification $_POST, $_GET, 
 [2011-02-21 20:59 UTC]
-Package: Feature/Change Request +Package: Filter related
 [2012-02-22 13:29 UTC]
Fast forward to 2012, this is still wrong IMHO

Possible bugs:
1) documentation problem; the return value is defined as an array or false in case of failure - when the respective INPUT_XXX is not populated, it returns null; clearly not expected according to the documentation.
2) wrong behaviour in the code; if INPUT_XXX is not populated, I would expect the return value to be this: array_fill_keys(array_keys($definition), null)
 [2012-02-27 14:38 UTC]
The following patch has been added/updated:

Patch Name: consistent_filter_input_array
Revision:   1330353526
 [2018-05-05 16:00 UTC]
-Status: Open +Status: Verified -Type: Feature/Change Request +Type: Documentation Problem -Assigned To: +Assigned To: cmb
 [2018-05-05 16:00 UTC]
Changing the behavior of filter_input_array() for cases where
INPUT_* is not set would cause a BC break, and in my opinion would
therefore require the RFC process[1], since filter_input_array()
works this way since its introduction[2].  Thus, I'm changing to
doc bug.

It is also noteworthy to mention that filter_input_array() returns
FALSE, if the input array is not populated, and the
FILTER_NULL_ON_FAILURE flag is set in the $definition array[3].

Finally, indeed the example is seriously wrong.

[1] <>
[2] <>
[3] <>
 [2018-05-05 16:24 UTC]
Automatic comment from SVN on behalf of cmb
Log: Fix #42608: Example 660 (filter_input_array) is wrong
 [2018-05-05 16:25 UTC]
-Status: Verified +Status: Closed
 [2018-05-05 16:25 UTC]
This bug has been fixed in the documentation's XML sources. Since the
online and downloadable versions of the documentation need some time
to get updated, we would like to ask you to be a bit patient.

Thank you for the report, and for helping us make our documentation better.This bug has b
 [2020-02-07 06:05 UTC]
Automatic comment on behalf of cmb
Log: Fix #42608: Example 660 (filter_input_array) is wrong
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sat May 18 11:01:34 2024 UTC