TL;DR
If you want to use filter_input()
's filter option then choose POST
, GET
, or COOKIE
as your request type. But there are ways to get REQUEST
style behaviour.
note: GET
is conventionally used for sending details of a request for retrieving data, while POST
is used for submitting data to be stored on the server.
You have a few options:
Indeed, so far (as of PHP 7.2) only INPUT_GET, INPUT_POST, INPUT_COOKIE, INPUT_SERVER, or INPUT_ENV
have been implemented. But you can still get INPUT_REQUEST style behaviour, or other options might actually fulfill your needs.
Implement INPUT_REQUEST Yourself: (I don't recommend this) you can use INPUT_GET
, INPUT_POST
and INPUT_COOKIE
to implement the behaviour you would expect from the currently non-extant INPUT_REQUEST
by running one, and if that didn't get anything running the next and so on, as follows.
`$test_filter = filter_input(INPUT_COOKIE, 'test') ?? filter_input(INPUT_POST, 'test') ?? filter_input(INPUT_GET, 'test');`
Use INPUT_GET or INPUT_POST: if you know which of PUSH or GET will be used to send the request then use the corresponding option. Data sent in the query string of the url will be retrieved using INPUT_GET
for example.
Suppress the Superglobal Warning: you can choose which warnings netbeans shows you by going to Windows: Tools -> Options -> Editor -> Hints
Mac: NetBeans -> Preferences -> Editor -> Hints
and deselecting Superglobals
or whatever subset of that you don't want.
Final Note: filter_input()
has a third argument that is the actual filter part; if you're using filter_input anyway then you might as well actually use the filter. If you omit the argument then:
If omitted, FILTER_DEFAULT will be used, which is equivalent to FILTER_UNSAFE_RAW. This will result in no filtering taking place by default.