When and why should $_REQUEST be used instead of $_GET / $_POST / $_COOKIE?

前端 未结 6 1456

Question in the title.

And what happens when all 3 of $_GET[foo], $_POST[foo] and $_COOKIE[foo] exist? Which one of them gets

6条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2020-12-01 11:18

    Sometimes you might want the same script to be called with several different ways. A form submit and an AJAX call comes to mind. In most cases, however, it´s better to be explicit.

    Also, see http://docs.php.net/manual/en/ini.core.php#ini.request-order on how the different sources of variables overwrite each other if there is a name collision.

提交回复
热议问题