Warning: filter_input(): INPUT_REQUEST is not yet implemented

允我心安 提交于 2019-12-02 10:50:53

问题


I am trying to modify this line.

Originally, it was

$cmd = $_REQUEST["cmd"];

Then, I changed to this by reading this post a link at Stackoverflow.

$cmd = filter_input(INPUT_REQUEST, "cmd");

But, I am still getting bottom error:

Warning: filter_input(): INPUT_REQUEST is not yet implemented

When I read other article a link, it says "INPUT_REQUEST is not a valid type."

What is solution here?


回答1:


Per the documentation (and your error message, and the answer to the SitePoint Q&A you reference), it's not a valid parameter. The documentation says:

One of INPUT_GET, INPUT_POST, INPUT_COOKIE, INPUT_SERVER, or INPUT_ENV.

There is no such thing as INPUT_REQUEST for this function.

What is solution here?

Use one of the parameters that actually exists.




回答2:


TL;DR If you want to use filter_input()'s filter option then choose POST, GET, or COOKIE as your request type. But that's not your only option.

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 it's behaviour.

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.



来源:https://stackoverflow.com/questions/46370484/warning-filter-input-input-request-is-not-yet-implemented

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!