100: How does PHP obtain the PUT and DELETE request parameters?

Source: Internet
Author: User
100: How does PHP obtain the parameter Hi of the PUT and DELETE requests? hello, everyone. I am trying to use PHP to implement the RESTful & nbsp; API interface. now I have encountered a problem: when the REQUEST type is POST or GET, PHP can easily obtain the parameters input by the client through $ _ POST, $ _ GET, and $ _ REQUEST; however, if the request type is PUT or DELETE 100, how does PHP obtain the parameters of the PUT and DELETE requests?
Hi everyone, I'm trying to use PHP to implement the RESTful API. now I have encountered a problem:

When the REQUEST type is POST or GET, PHP can easily obtain the parameters input by the client through $ _ POST, $ _ GET, and $ _ REQUEST; however, when the request type is PUT or DELETE, I don't know which method PHP should use to obtain parameters.

Have you ever encountered a similar problem? Please kindly advise me ~ PHP RESTful shared:
------ Solution --------------------
The most stupid method: $ METHOD = $ _ SERVER ['request _ method']
Then Judge
------ Solution --------------------
At the end of this post, xuzuning edited some. php at 11:52:45 on
$ Type = $ _ SERVER ['request _ method'];
Parse_str (file_get_contents ('php: // input'), $ data );
$ Data = array_merge ($ _ GET, $ _ POST, $ data );
// Perform operations based on the value of $ type

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.