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 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.
Reply to discussion (solution)
What does lz want to express.
In any case, I would like to share my experiences with you.
I feel that every post can help me, and the author's experience is very good.
Is this a summary of my own learning?
$ _ 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
I thought LZ was using PHP to develop a Web server similar to Apache. it turned out to be ....
I think this should be a soft article promotion... See the last line in seconds .. Okay, I think more.
What does lz want to express. I just want to share my own problems. maybe I can help someone who needs them on a temporary basis ......
Is this a summary of my own learning? That's okay, but I may not use php after I finish this server. after all, it's a temporary need ......
$ _ 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 identification of data type is the application/x-www.form-urlencoded standard data type I was not through the system learning is to check some of the information it understands not deep thank you for your advice ......