PHP Development: The POST method of the REST interface obtains the object submitted by the client according to the REST specification, and adds the POST method for data. If you submit an object using the traditional application/x-www-form-urlencoded form, you need to extract the values and values of each field and put them in the parameters. after the server receives the information, then it is restored to the corresponding object for processing, which is additional work for the client and the server.
The best way to transmit objects between the client and the server is to use json or xml. both the client and the server have corresponding tools to serialize or deserialize objects. Individuals prefer json, code is more concise, and conversion is more convenient.
When the client submits a request, set Content-Type to "application/json; charset = UTF-8", tell the SERVER that the message body is json, the SERVER determines $ _ SERVER ['content _ type'], if it is json, use file_get_contents ('php: // input') to obtain the message body. the serialized json string of the object is obtained and processed accordingly.
©2016, frozen fish. please respect the author's Labor achievements, copy and repost, and keep the link on this site! Application Development notes