PHP retrieves post JSON data

Source: Internet
Author: User
Tags php source code

Introduction: This is a detailed page for PHP to obtain post JSON data. It introduces the knowledge, skills, and experience related to PhP, PHP, post, and json php to obtain post JSON data, and some PHP source code.

Class = 'pingjiaf' frameborder = '0' src = 'HTTP: // biancheng.dnbc?info/pingjia.php? Id = 359497 'rolling = 'no'>

InProgramWhen passing data, you will find that $ _ post cannot be used to obtain data at all. However, in firebug, we can see that post actually contains JSON data.

After print_r (file_get_contents ("PHP: // input") is used, JSON data is obtained.

So what is Php: // input?

For introduction to PHP: // input, the PHP official manual provides a clear overview of it.

"PHP: // input allows you to read raw post data. It is a less memory
Intensive alternative to $ http_raw_post_data and does not need any
Special PHP. ini directives. php: // input is not available
Enctype = "multipart/form-data ".

The translation is like this:

"PHP: // input can read post data that has not been processed. Compared with $ http_raw_post_data, it puts less pressure on memory and does not need
Special PHP. ini settings. PHP: // input cannot be used for enctype = multipart/form-data ".

1, Content-Type
When the value is application/X-WWW-form-urlencoded, PHP will fill in the corresponding data of the HTTP Request body in the array $ _ post and fill in
The data in the $ _ post array is the result of urldecode () parsing. (In fact, besides the Content-Type, there are also multipart/form-
Data indicates that the data is form data. We will introduce it later)

2, PHP: // input data, as long as the Content-Type is not multipart/form-data (this condition will be described later ). PHP:
// The input data is consistent with that of the HTTP entity body. The consistent data length is specified by Content-Length.

3. Only when the Content-Type is application/X-WWW-form-urlencoded and the submission method is the POST method, $ _ post
Data is "consistent" with PHP: // input data (marked with quotation marks, indicating that they are in different formats and the content is consistent. In other cases, they are inconsistent.

4. php: // input cannot read $ _ get data. The reason is that the $ _ get data is written in the path field of the HTTP Request Header as query_path, rather than in the HTTP Request body.

I believe everyone is right
PHP: // input. So what is $ http_raw_post_data? $ Http_raw_post_data is Php
A built-in global variable. It is used by PHP to change the original post data when the Content-Type cannot be recognized.
$ Http_raw_post_data. It cannot read Post Data whose content-type is multipart/form-data. Set
In PHP. ini, if the always_populate_raw_post_data value is on, PHP will always change the post data.
$ Http_raw_post_data.

Study Note 1, coentent-type only when the value is application/X-WWW-data-urlencoded and multipart/form-data, PHP will fill in the corresponding data in the HTTP request packet with the global variable $ _ post

2. When PHP cannot recognize the Content-Type type, it will fill in the corresponding data in the HTTP request package with the variable $ http_raw_post_data

3. When the coentent-type is not multipart/form-data, PHP will not fill in the corresponding data in the HTTP request packet in PHP: // input; otherwise, it will be used in other cases. Length Specified by coentent-length.

4. php: // input data is consistent with $ _ post data only when the Content-Type is application/X-WWW-data-urlencoded.

5. php: // the input data is always the same as $ http_raw_post_data, but PHP: // the input data is more efficient than $ http_raw_post_data, and PHP. ini does not require special settings.

6. php will fill in the query_path section of the path field with the global variable $ _ get. Normally, the HTTP Request Submitted by The get method has no body.

Love J2EE follow Java Michael Jackson video station JSON online tools

Http:// pageno: 1.

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: 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.