-
Notifications
You must be signed in to change notification settings - Fork 860
Documentation of filter_input -> return values looks incorrect #4361
Copy link
Copy link
Open
Labels
Description
From manual page: https://php.net/function.filter-input
The Return Value section reads:
On success returns the filtered variable.
If the variable is not setfalseis returned.
On failurefalseis returned, unless theFILTER_NULL_ON_FAILUREflag is used, in which casenullis returned.
It does not seem to return null when the variable is not set:
$foo = filter_input(INPUT_GET, "x", FILTER_VALIDATE_INT);
var_dump($foo);
The above code produces the following results for the query strings:
localhost/test.php
NULL
localhost/test.php?x=
bool(false)
localhost/test.php?x=asdf
bool(false)
localhost/test.php?x=1234
int(1234)
No flags were set and notice that first case prints NULL. I believe this function always returned NULL if query string/post/cookie/etc variable is not present and the current documentation is incorrect about return values.
Reactions are currently unavailable