The main difference between Get and Post is that Get transmits data through Url, while Post does not allow users to see the specific information transmitted. This difference determines the use of the two. The Get method is mainly used for searching, while the Post method is mainly used to transmit user operation information to the server. The following is the detailed difference between Get and Post:
Security of GET and POST
1. GET is requested through URL, which can be seen directly and transmitted in clear text.
2. POST is requested through the request header, which can be seen by developer tools or packet capture, and is also in clear text.
3. GET requests will be saved in the browser history and may also be saved in the Web log.
get submission, the requested data will follow the url (uniform resource positioning), low security
post submission, put the submitted data in the body of the http package, security High
Data size of GET and POST
GET: Certain browsers and servers have restrictions on URL length. For example, IE’s limit on URL length is 2083 bytes ( 2K 35). For other browsers, such as Netscape, FireFox, etc., there is theoretically no length limit, and the limit depends on the support of the operating system. The amount of data transmitted by Get is small because it is limited by the length of the URL, but it is more efficient;
POST: Because the value is not transmitted through the URL, the data is theoretically not limited. Post can transmit a large amount of data, so you can only use the Post method when uploading files;
The transmission data character format is different
get limits the value of the data set of the Form form to ASCII characters cannot be set through request.setCharacterEncoding("utf-8");. Chinese characters obtained by the server may be garbled!
post supports the entire character set ISO10646, and can display Chinese characters correctly through request.setCharacterEncoding("utf-8");.
The server side obtains data in different ways
Get is on the server side$_GET;
Post is on the server side$_POST
GET is idempotent, POST is not idempotent
Idempotence means that the same request method has the same effect if executed multiple times and executed only once.
1. According to RFC specifications, PUT, DELETE and security methods are idempotent. Although it is a specification, there is no guarantee whether the server implementation is idempotent.
2. The introduction of idempotence is mainly to deal with the situation where the same request is sent repeatedly, such as losing the connection before the request responds. If the method is idempotent, you can safely resend the request. This is also the reason why the browser will prompt the user when encountering POST when backing/refreshing: POST semantics are not idempotent, and repeated requests may bring unexpected consequences.
3. For example, in the scenario of Weibo, the semantics of GET will be used in the scenario of "Look at the latest 20 Weibo posts on my Timeline", while the semantics of POST will be used in the scenario of " In a scenario like posting on Weibo, commenting, and liking.
For more PHP related knowledge, please visit php中文网!
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!

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Dreamweaver Mac version
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

EditPlus Chinese cracked version
Small size, syntax highlighting, does not support code prompt function

MinGW - Minimalist GNU for Windows
This project is in the process of being migrated to osdn.net/projects/mingw, you can continue to follow us there. MinGW: A native Windows port of the GNU Compiler Collection (GCC), freely distributable import libraries and header files for building native Windows applications; includes extensions to the MSVC runtime to support C99 functionality. All MinGW software can run on 64-bit Windows platforms.

SecLists
SecLists is the ultimate security tester's companion. It is a collection of various types of lists that are frequently used during security assessments, all in one place. SecLists helps make security testing more efficient and productive by conveniently providing all the lists a security tester might need. List types include usernames, passwords, URLs, fuzzing payloads, sensitive data patterns, web shells, and more. The tester can simply pull this repository onto a new test machine and he will have access to every type of list he needs.
