Home > Article > Backend Development > What is the difference between get and post requests in php
We know that there are many request methods, such as: GET, POST, PUT, DELETE, OPTIONS, etc. Among them, GET and POST are the most common, so what are these two request methods? What's the difference?
The differences are as follows:
Format of data submitted by GET method:
1. Format: index.php?username=jack&password=123;(Put The parameter data queue is added to the URL pointed to by the action attribute of the submitted form, and the values correspond to the fields in the form one-to-one)
2. There is no space between the parameter name and the parameter value
3. Parameters The value does not need to use single or double quotation marks including
(online learning video sharing: php video tutorial)
Features of submitting data using GET method:
1. The get method splices parameters after the url, and can only transfer data in the form of text
2. The amount of data transferred is small, about 4KB (different browsers will vary)
3. Low security, the data will be displayed in the address bar
4. Fast, usually used for requests that do not require high security
POST submission Data:
Through the HTTP post mechanism, each field in the form and its content are placed in the html header and transmitted to the url address pointed to by the action attribute. The user cannot see this process.
Characteristics of data submitted through POST:
1. High security
2. The amount of data transferred is large, and the request does not require data length.
3. The request will not be cached, nor will it be retained in the browser history
4. It is used in situations with relatively high security requirements such as passwords, and the amount of data submitted is relatively large. : Such as publishing articles and uploading files.
Recommended related articles and tutorials: php tutorial
The above is the detailed content of What is the difference between get and post requests in php. For more information, please follow other related articles on the PHP Chinese website!