Use curl to understand $ GLOBALS ['http _ RAW_POST_DATA '], $ _ POST, php: // input

Source: Internet
Author: User
Use curl to understand the request code sent by $ GLOBALS [HTTP_RAW_POST_DATA], $ _ POST, and php: input.

Post. php

     

Code for receiving the request

Url. php

      

Post. php execution result

HTTP_RAW_POST_DATA: post:

Array ([a] => 123 | B = 2 [c] => 3)

Input:

A = 123 | B = 2 & c = 3

CONTENT_TYPE: application/x-www-form-urlencoded

1. it indicates that if content-type is not passed, php defaults to application/x-www-form-urlencoded. php can recognize this, and $ GLOBALS ["HTTP_RAW_POST_DATA"] is blank, post is the generated array after Recognition. php: // input gets the original data.

If there is no data in the 123456 $ _ POST because no key is used, php: // The input is still the original data.

2. if you set $ header [] = "content-type: text/xml ";

The execution result is

HTTP_RAW_POST_DATA:

A = 123 | B = 2 & c = 3

Post:

Array ()

Input:

A = 123 | B = 2 & c = 3

CONTENT_TYPE: text/xml

At this time, there is no data in Post, and there is data in HTTP_RAW_POST_DATA.

Php: // inputAlways raw data

In summary:

When content-type is the default application/x-www-form-urlencoded, php can process Post data and generate a $ _ POST array $ GLOBALS ["HTTP_RAW_POST_DATA"] in combination. no value

When content-type is of another type, php cannot process it and cannot generate the $ _ POST array. Both the original data in $ GLOBALS ["HTTP_RAW_POST_DATA"] and php: // input are original data.

Php: // input is the original post data in any case

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.