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!

The article compares ACID and BASE database models, detailing their characteristics and appropriate use cases. ACID prioritizes data integrity and consistency, suitable for financial and e-commerce applications, while BASE focuses on availability and

The article discusses securing PHP file uploads to prevent vulnerabilities like code injection. It focuses on file type validation, secure storage, and error handling to enhance application security.

Article discusses best practices for PHP input validation to enhance security, focusing on techniques like using built-in functions, whitelist approach, and server-side validation.

The article discusses strategies for implementing API rate limiting in PHP, including algorithms like Token Bucket and Leaky Bucket, and using libraries like symfony/rate-limiter. It also covers monitoring, dynamically adjusting rate limits, and hand

The article discusses the benefits of using password_hash and password_verify in PHP for securing passwords. The main argument is that these functions enhance password protection through automatic salt generation, strong hashing algorithms, and secur

The article discusses OWASP Top 10 vulnerabilities in PHP and mitigation strategies. Key issues include injection, broken authentication, and XSS, with recommended tools for monitoring and securing PHP applications.

The article discusses strategies to prevent XSS attacks in PHP, focusing on input sanitization, output encoding, and using security-enhancing libraries and frameworks.

The article discusses the use of interfaces and abstract classes in PHP, focusing on when to use each. Interfaces define a contract without implementation, suitable for unrelated classes and multiple inheritance. Abstract classes provide common funct


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

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

Atom editor mac version download
The most popular open source editor

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.

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

Dreamweaver Mac version
Visual web development tools

Notepad++7.3.1
Easy-to-use and free code editor