php的$_request,php中$_REQUEST一个注意点

问题

说起REQUEST,大家都知道的是它是REQUEST,大家都知道的是它是_GET和$_POST的集合。但是如果你有心的话,查一下文档,会看到:

$_REQUEST

An associative array that by default contains the contents of GET,GET,_POST and $_COOKIE.

这里说REQUEST默认是REQUEST默认是_GET, POST,POST,_COOKIE的集合,结果我使用我本地的php查看了一下发现只有GET,GET,_POST, 没有$_COOKIE!! 难道文档是错的?

答案

其实changelog中有给出解释:

c01e0fcc0c6b73f700ac229169c71f24.png

版本5.3以上,php.ini中有request_order属性来设置$_REQUEST。查了下php.ini, request_order设置成为了GP(Get and Post)。

request_order的官网描述:

request_order string

This directive describes the order in which PHP registers GET, POST and Cookie variables into the _REQUEST array. Registration is done from left to right, newer values override older values.

If this directive is not set, variables_order is used for $_REQUEST contents.

Note that the default distribution php.ini files does not contain the 'C' for cookies, due to security concerns.

原来是G,P,C分别代表Get,Post,Cookie,5.3以上的版本request_order默认是设置成GP的,并不包含C,即REQUEST默认只包含REQUEST默认只包含_GET和$_POST !! (所以官网文档有一定的误导)。

也同时说一下G,P,C的先后顺序就是设置的array的覆盖顺序。

提醒下如果你是使用fpm-php实验的话,改了php.ini后你需要重启php-fpm

本文转自轩脉刃博客园博客,原文链接:http://www.cnblogs.com/yjf512/archive/2012/10/12/2720967.html,如需转载请自行联系原作者

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值