Is there a PHP variable that includes a merge of $ _GET and $ _POST?

$ _ REQUEST includes cookies that I DO NOT want in my form messages.

+3
source share
6 answers

The php.ini value is responsible for what is in $ _REQUEST, this isvariables_order

Default: variables_order "EGPCS"

Change this in php.ini to:

GP

so that it only includes $ _GET and $ _POST

You may not want to do this.

Typically in a web application, you use the $ _GET values ​​to choose what to show, and the $ _POST values ​​to convey what needs to be changed on the web page (or user actions that change the state as a whole). Generally not recommended to mix them :)

: $_REQUEST $_GET/$_POST/$_COOKIE?

, , : $_REQUEST []?

mario:)

+11
$new_array = array_merge($_GET, $_POST);
+3

$_REQUEST, php.ini variables_order. .

+3

$_REQUEST . $_GET, $_POST $_REQUEST.

+3

:

$_REQUEST = array_merge($_GET, $_POST);

Which has the advantage of explicitly listing the order that you need so that you do not redefine what you did not expect, because the REQUEST order has been disabled.

+2
source

I would be explicit.

If GET / POST merging is required in some context, then apply it, but I would avoid the egregious clobber. This merge can easily be done behind an element and hidden behind a beautiful, neat and default shell - perhaps even with a sanitizing / coversion level right there and there.

No magic is required. Happy coding.

+2
source

Source: https://habr.com/ru/post/1795358/


All Articles