Home > Article > Backend Development > What is the difference between get and post in php?
The difference between get and post in php: 1. The amount of data transferred by get is small and cannot be larger than 2KB; while the amount of data transferred by post is larger and is generally unrestricted by default. 2. Get submission, the requested data will follow the URL, which is low security; post submission, the submitted data is placed in the body of the http package, which is high security.
Recommended: "PHP Video Tutorial"
What is the difference between get and post in PHP? The following article summarizes the differences between get and post for everyone. It has certain reference value. Friends in need can refer to it. I hope it will be helpful to everyone.
The first difference between get and post:
GET is harmless when the browser rolls back, while POST will submit the request again.
The URL address generated by GET can be Bookmarked (marked), but POST cannot.
GET requests will be actively cached (stored) by the browser, while POST will not unless manually set.
GET requests can only be URL encoded, while POST supports multiple encoding methods.
GET request parameters will be completely retained in the browser history, while parameters in POST will not be retained.
There is a length limit on the parameters transmitted in the URL for the GET request, but there is no length limit for POST.
Regarding the data type of parameters, GET only accepts ASCII (American Standard Code for Information Interchange) characters, while POST has no restrictions.
GET is less secure than POST because the parameters are directly exposed on the URL, so it cannot be used to pass sensitive information.
GET parameters are passed through the URL, and POST is placed in the Request body.
The second difference between get and post
1. GET is requested through the URL, which can be seen directly and transmitted in plain text; POST is requested through the request header, You can see it in developer tools or packet capture. It is also in plain text.
get adds the parameter data queue to the URL pointed to by the ACTION attribute of the submitted form. The value corresponds to each field in the form. It can be seen in the URL.
Post uses the HTTP post mechanism to place each field in the form and its content in the HTML HEADER and transmit it to the URL address pointed to by the ACTION attribute. Users cannot see this process.
2. The amount of data transferred by get is small and cannot be larger than 2KB.
Post transmits a large amount of data and is generally unrestricted by default.
3. The security of get is very low, but the security of post is high. But the execution efficiency is better than the Post method.
Note: Post is just more secure than get, but it does not mean it is foolproof. In programming languages, security is the most important (in output statements, echo, print, var_dump and other output statements must be To use filtering functions such as htmlentiti() or regular filtering);
Related recommendations:php training
The above is the detailed content of What is the difference between get and post in php?. For more information, please follow other related articles on the PHP Chinese website!