How to obtain json data in post using php

Source: Internet
Author: User

I suddenly thought that I had used flash to spread the binary image to php. I got it with $ GLOBALS ['HTTP _ RAW_POST_DATA.
So I checked it in depth, the original PHP by default only recognize the application/x-www.form-urlencoded standard data type, therefore, the text, xml, soap, or application/octet-stream contents cannot be parsed. If you use the $ _ POST array to receive the content, it will fail! Therefore, the prototype is retained and sent to $ GLOBALS ['HTTP _ RAW_POST_DATA '] for receiving.

HTTP_RAW_POST_DATA of php
The Content-Type = text/xml Type is used to submit an xml document Content to the php server. How can I obtain the POST data.
The RAW/uninterpreted http post information can be accessed: $ GLOBALS ['HTTP _ RAW_POST_DATA '] This is useful in cases where the post Content-Type is not something PHP understands (such as text/xml ).
Because PHP only recognizes the application/x-www.form-urlencoded standard data type by default, the content of the type such as text/xml cannot be parsed as $ _ POST array, so the prototype is retained, it is sent to $ GLOBALS ['HTTP _ RAW_POST_DATA '] for receiving.
Another php: // input can also implement this function.
Php: // input allows reading original POST data. Compared with $ HTTP_RAW_POST_DATA, it puts less pressure on the memory and does not require any special php. ini settings. Php: // input cannot be used for enctype = "multipart/form-data ".

Application

A.htm
Copy codeThe Code is as follows:
<Form action = "post. php" method = "post">
<Input type = "text" name = "user">
<Input type = "password" name = "password">
<Input type = "submit">
</Form>

Post. php
Copy codeThe Code is as follows:
<? Echo file_get_contents ("php: // input");?>

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.