An issue you need to pay attention to when using $_REQUEST in PHP_PHP Tutorial

WBOY
Release: 2016-07-21 15:11:25
Original
984 people have browsed it

Question
Speaking of $_REQUEST, everyone knows that it is a collection of $_GET and $_POST. But if you are interested, check the documentation and you will see:

$_REQUEST

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

It is said here that $_REQUEST defaults to a collection of $_GET, $_POST, and $_COOKIE. As a result, I used my local php to check and found that there were only $_GET, $_POST, and no $_COOKIE! ! Could it be that the documentation is wrong?

Answer
In fact, there is an explanation in the changelog:

Version 5.3 and above, there is a request_order attribute in php.ini to set $_REQUEST. After checking php.ini, request_order is set to GP (Get and Post).

request_order’s official website description:

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.

It turns out that G, P, and C represent Get, Post, and Cookie respectively. In version 5.3 and above, request_order is set to GP by default and does not include C, that is, $_REQUEST only contains $_GET and $_POST by default!! (So The official website documentation is somewhat misleading).

Also, the order of G, P, C is the covering order of the set array.

As a reminder, if you are using fpm-php for experiments, you need to restart php-fpm after changing php.ini

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/326875.htmlTechArticleQuestion Speaking of $_REQUEST, everyone knows that it is a collection of $_GET and $_POST. But if you are interested, check the documentation and you will see: $_REQUEST An associative array that by de...
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template