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 set false is returned.
On failure false is returned, unless the FILTER_NULL_ON_FAILURE flag is used, in which case null is 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.
From manual page: https://php.net/function.filter-input
The Return Value section reads:
It does not seem to return
nullwhen the variable is not set:The above code produces the following results for the query strings:
No flags were set and notice that first case prints
NULL. I believe this function always returnedNULLif query string/post/cookie/etc variable is not present and the current documentation is incorrect about return values.