php中REQUEST的用法

版权声明:孤 https://blog.csdn.net/Wu000999/article/details/83115946

在php手册中,这个变量解释为:"默认情况下包含了 $ _GET,$_POST 和 $_COOKIE 的数组。"

注意其中包含cookie的内容,做个测试:
在这里插入图片描述

输出结果:
Array ( )

并没有取到cookie的内容。

再看手册,下面有一行:
5.3.0 引入 request_order。该指令会影响 $_REQUEST 的内容
打开php.ini,找到request_order:

 ; This directive determines which super global data (G,P,C,E & S) should
    ; be registered into the super global array REQUEST. If so, it also determines
    ; the order in which that data is registered. The values for this directive are
    ; specified in the same manner as the variables_order directive, EXCEPT one.
    ; Leaving this value empty will cause PHP to use the value set in the
    ; variables_order directive. It does not mean it will leave the super globals
    ; array REQUEST empty.
    ; Default Value: None
    ; Development Value: "GP"
    ; Production Value: "GP"
    ; http://php.net/request-order
    request_order = "GP"

翻译:
这条指令确定了哪些超全局数据该被注册到超全局数组REQUEST中,这些超全局数据包括G(GET),P(POST),C(COOKIE),E(ENV),S(SERVER)。这条指令同样指定了这些数据的注册顺序,换句话说GP和PG是不一样的。注册的顺序是从左至右,即右侧的值会覆盖左侧的。比如,当设置为GPC时,COOKIE > POST > GET,依次覆盖。如果这个项被设置为空,php将会使用指令variables_order的值来指定。

猜你喜欢

转载自blog.csdn.net/Wu000999/article/details/83115946