PHP: $_GET and $_POST in functions?

前端 未结 3 2068
滥情空心
滥情空心 2020-11-30 14:13

I am flabbergasted by the code, where the GET-values, such as $_GET[\'username\'], are not included as parameters to functions.

When do you need to inc

3条回答
  •  醉梦人生
    2020-11-30 14:33

    $_GET and $_POST are global variables. They have values, not methods.

    It is their values you want to send to functions, and classes/functions should generally be unaware of anything outside them, like where the data comes from. Many use the shortcut of using the global variables in functions, and thus limiting the usability of their functions.

提交回复
热议问题