In php, you need to pay attention to the $ _ REQUEST _ PHP Tutorial.

Source: Internet
Author: User
Pay attention to the usage of $ _ REQUEST in php. When talking about $ _ REQUEST, we all know that it is a collection of $ _ GET and $ _ POST. If you are interested, check the document and you will see: $ _ REQUESTAnassociativearraythatbyde Problem
Speaking of $ _ REQUEST, we all know that it is a collection of $ _ GET and $ _ POST. But if you are interested, check the document and you will see:

$ _ REQUEST

An associative array that by default contains the contents of $ _ GET, $ _ POST and $ _ COOKIE.

Here, $ _ REQUEST is a set of $ _ GET, $ _ POST, and $ _ cookies by default. as a result, I checked it using my local php and found that only $ _ GET, $ _ POST, no $ _ COOKIE !! Is the document wrong?

Answer
In fact, changelog has explained the following:

For versions later than 5.3, php. ini has the request_order attribute to set $ _ REQUEST. Check php. ini and set request_order to GP (Get and Post ).

Description on the official website of 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.

The original versions are G, P, and C, which respectively represent Get, Post, Cookie, and request_order of versions later than 5.3 are set to GP by default and do not contain C, that is, $ _ REQUEST only includes $ _ GET and $ _ POST by default !! (Therefore, the official website documents are misleading ).

Also, the order of G, P, and C is the overwrite sequence of the set array.

Note: If you are using the fpm-php experiment, you need to restart php-fpm after modifying php. ini.

Starting with $ _ REQUEST, we all know that it is a collection of $ _ GET and $ _ POST. But if you are interested, check the document and you will see: $ _ REQUEST An associative array that by de...

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.