Home  >  Article  >  Backend Development  >  The difference between $_post and $_get_PHP tutorial

The difference between $_post and $_get_PHP tutorial

WBOY
WBOYOriginal
2016-07-13 16:58:391241browse

The difference between $_post and $_get

1. Get is used to obtain data from the server, while Post is used to transfer data to the server.
2. Get adds the data in the form to the URL pointed to by the action in the form of variable=value, and the two are connected using "?", and each variable is connected using "&"; Post is to add the data in the form to the URL pointed to by the action. The data is placed in the data body of the form and passed to the URL pointed to by the action according to the corresponding variables and values.
3. Get is unsafe because during the transmission process, the data is placed in the requested URL, and many existing servers, proxy servers or user agents will record the requested URL in a log file and then place it somewhere. place, so that some private information may be seen by third parties. In addition, users can also see the submitted data directly on the browser, and some internal system messages will be displayed in front of the user. All Post operations are invisible to users.
4. The amount of data transferred by Get is small, mainly because it is limited by the URL length; while Post can transfer a large amount of data, so only Post can be used to upload files.
5. Get limits the value of the data set in the Form form to ASCII characters; while Post supports the entire ISO10646 character set.
6. Get is the default method of Form.
7. Post requests are only suitable for transfer requests from page to page. If the address is entered directly from the address bar, the request cannot form a post request. In the case of post, the field of the previous page is used as The parameters are passed to the server. In the case of get, the parameters rely on the string after "?" in the address to form the parameters. The address specified by the src attribute in the frame is exactly the same as the address entered from the address bar, and the request issued is a get request.

To put it simply, the URL is generally passed through the get method. For example, you enter
in the browser.
xxx.php?a=1&b=2
Then it is $_GET['a'] $_GET['b]

If you submit it in a form, and the form specifies method=post, such as



What is submitted at this time is $_POST['a']. Of course, if you specify his method=get, what he submits is the GET method

GET and POST are two methods for transmitting data. The disadvantage of the GET method is that there is a limit on the byte length. Therefore, forms generally use the POST method.

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/631377.htmlTechArticleThe difference between $_post and $_get 1. Get is used to obtain data from the server, while Post is used Pass data to the server. 2. Get adds the data in the form in the form of variable=value...
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