0
$_REQUEST[$k] = isset($_GET[$k]) ? $_GET[$k] : $_POST[$k];

or

$_REQUEST[$k] = isset($_POST[$k]) ? $_POST[$k] : $_GET[$k];

Which is the case,reason?

wamp
  • 5,789
  • 17
  • 52
  • 82
  • 1
    *(suggested reading)* [What's wrong with using $_REQUEST?](http://stackoverflow.com/questions/2142497/whats-wrong-with-using-request) and [Does $_REQUEST have security problem?](http://stackoverflow.com/questions/1149118/does-request-have-security-problem) – Gordon Sep 07 '10 at 08:31

3 Answers3

3

$_REQUEST is the union of $_GET, $_POST, and $_COOKIE where variables_order and since PHP 5.3 request_order defines the order.

The default order is GET, POST, and then cookie. That means POST parameters overwrite existing GET parameters and cookies overwrite existing POST and GET parameters.

Gumbo
  • 643,351
  • 109
  • 780
  • 844
1

ini directive "variables_order" is believed* to affect $_REQUEST, see http://php.net/manual/en/ini.core.php

*"believed" because i never used either that or $_REQUEST itself.

user187291
  • 53,363
  • 19
  • 95
  • 127
0

$_REQUEST is simply the array that PHP puts all of the GET and POST and COOKIE parameters into, with precedence in that order in the case of conflicts.

http://php.net/manual/en/reserved.variables.request.php

pauljwilliams
  • 19,079
  • 3
  • 51
  • 79