Solutions to HTTP server development in PHP

Source: Internet
Author: User
For more information about HTTP server development in PHP recently due to work needs, we need to create a server for a mobile game to manage the game rankings. after my introduction, I think it is relatively simple to use php for development, so I learned the basic php syntax and checked a lot of information about how to develop the server on the Internet. Here I will talk about the questions I encountered when I was working on my own server.
Recently, due to work needs, I want to create a server for a mobile game to manage the game rankings. after some introductions, I think it is relatively simple to use php for development, so I learned the basic php syntax and checked a lot of information about how to develop the server on the Internet.
Here I will talk about the problems I encountered when I was working on the server. I hope that new users who need to develop php servers temporarily can get help. as for experts, you should ignore me.
Many of the information I found on the internet is about how php simulates the sending of http requests. there is very little information about how the server obtains client requests, which may have been learned by the system, however, my temporary study is really a serious injury.
The php server that receives client data can be obtained through $ _ POST, $ _ GET, $ _ REQUEST. The client needs to use the corresponding $ _ post and $ _ get to submit data. $ _ REQUEST seems to be okay.
As for the difference between $ _ POST and $ _ GET, you can find too many items on Baidu.
$ _ POST, $ _ GET returns the parameters passed by your client. you can process these parameters to complete the function. to return data to the client, you only need echo.
If the client uses the get method to send the request, to get data is very simple, you only need to use $ _ SERVER ['query _ string'] to obtain the information, information from the http://hi.baidu.com/iigyphfsjfgjkye/item/f180b2fbc5aa18ee1b111fc1 more information to view it

I am working on a php server this time. I don't know why. I cannot GET data with $ _ POST, $ _ GET, $ _ REQUEST. So I found $ GLOBALS [$ HTTP_RAW_POST_DATA] and file_get_contents ("http: // input") to get the data.
Both of the above methods can obtain the first type of data in the post request from the client.
I used the second $ request = file_get_contents ("http: // input") to get the post parameters from the client.

Here we will introduce a software Fidder that Baidu can download. This software can send get, post, and other requests in place of the client, and test whether your server can receive client requests.

------ Solution --------------------
$ _ POST, $ _ GET, $ _ REQUEST cannot obtain data. So we found $ GLOBALS [$ HTTP_RAW_POST_DATA] and file_get_contents ("http: // input") to get the data.

Is your data a binary stream?

$ _ POST: an array composed of variables passed through the http post method. Is an automatic global variable.
$ GLOBALS ['http _ RAW_POST_DATA ']: always generate the $ HTTP_RAW_POST_DATA variable containing the original POST data. This variable is generated only when data of the unrecognized MIME type is encountered. $ HTTP_RAW_POST_DATA is unavailable for enctype = "multipart/form-data" form data.
That is to say, basically $ GLOBALS ['http _ RAW_POST_DATA '] is the same as $ _ POST.

However, if the post data is not recognized by PHP, you can use $ GLOBALS ['http _ RAW_POST_DATA '] to receive the data, such as text/xml or soap.
 
PHP default recognized data type is the application/x-www.form-urlencoded standard data 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.