How evil is $_REQUEST and what are some acceptable Band-Aid countermeasures?

前端 未结 4 1784
礼貌的吻别
礼貌的吻别 2020-12-30 10:50

I\'ve come across a couple of popular PHP-related answers recently that suggested using the superglobal $_REQUEST, which I think of as code smell, because it re

4条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2020-12-30 11:08

    $_REQUEST is a evil as $_GET, $_POST and $_COOKIE. While i think there are valid scenarios for using $_REQUEST but there is one good reason not using $_REQUEST and label it as "bad practice".

    The main reason using $_REQUEST is that parameter can get transferred in $_POST or $_GET. By accessing $_REQUEST you don't have to check both $_GET and $_POST it the value is set. The problem is that the ini setting gpc_order can change the behavior how $_REQUEST is build. This setting may differ from server to server and you script may change the behavior.

提交回复
热议问题