Home  >  Article  >  Backend Development  >  What is the difference between post and get in php?

What is the difference between post and get in php?

烟雨青岚
烟雨青岚Original
2020-06-22 17:28:233251browse

What is the difference between post and get in php?

#What is the difference between post and get in php?

php basic knowledge The difference between post and get transmission methods

1.post is more secure (it will not be used as part of the url, not will be cached, saved in server logs, and browser browsing records)

2. The amount of data sent by post is larger (get has a URL length limit)

3. Post can send more Multiple data types (get can only send ASCII characters)

4.post transmits data to the server, and get obtains data from the server;

5.get will cache the data, And post will not

The process of post request:

1. The browser requests a tcp connection (first handshake)

2. The server agrees Perform tcp connection (second handshake)

3. The browser confirms and sends the post request header (the third handshake, this message is relatively small, so http will send the first data at this time )

4. The server returns a 100 continue response

5. The browser starts sending data

6. The server returns a 200 ok response

get Request process

1. The browser requests a tcp connection (first handshake)

2. The server agrees to a tcp connection (second handshake)

3. The browser confirms and sends the get request header and data (the third handshake, this message is relatively small, so http will send the first data at this time)

4. The server returns 200 ok response.

get expresses an idempotent, read-only, pure operation, that is, it should not produce other side effects (such as writing to the database) in addition to returning results, so most get requests (usually more than 90%) are directly cached by CDN, which can greatly reduce the burden on the web server.
The semantics expressed by post are non-idempotent and have side effects, so they must be processed by the web server.
Replacing all get requests with post means that all CDNs on the backbone network are abolished, and the number of requests that the web server has to handle will increase hundreds or thousands of times. Obviously this is not a smart approach!

Recommended tutorial: "php tutorial"

The above is the detailed content of What is the difference between post and get in php?. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn