php中$_REQUEST一个注意点

简介:

问题

说起 R E Q U E S T _GET和$_POST的集合。但是如果你有心的话,查一下文档,会看到:

$_REQUEST

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

这里说 R E Q U E S T _GET,  P O S T , _COOKIE的集合,结果我使用我本地的php查看了一下发现只有 G E T , _POST, 没有$_COOKIE!! 难道文档是错的?

 

答案

其实changelog中有给出解释:

clip_image001

版本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,即 R E Q U E S T _GET和$_POST !! (所以官网文档有一定的误导)。

 

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

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





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

相关文章
|
PHP
PHP $_POST
PHP $_POST
60 0
|
PHP 数据库
php cookie 代码
php cookie 代码
47 0
|
PHP
PHP $_REQUEST
PHP $_REQUEST
57 0
|
JSON Java PHP
PHP:Laravel获取请求头header
PHP:Laravel获取请求头header
420 0
|
PHP 开发者
php echo对象,php __toString
php echo对象,php __toString
103 0
|
Web App开发 PHP
php runtime 中 headers already sent 问题解决方案
本文旨在梳理 Cannot modify header information - headers already sent by (output started at xx 问题的原因,触发条件以及相应的解法
18609 1
|
PHP 关系型数据库
下一篇
oss创建bucket