Differences between $ _ GET $ _ POST $ _ REQUEST in PHP _ PHP Tutorial

Source: Internet
Author: User
Tags html header
Differences between $ _ GET $ _ POST $ _ REQUEST in PHP. Differences between $ _ GET $ _ POST $ _ REQUEST in PHP: $ _ REQUEST, $ _ POST, and $ _ GET are used to accept form data. I. differences and features between $ _ REQUEST and $ _ POST and $ _ GET $ _ REQUEST [] $ _ POST [] $ _ GET $ _ POST $ _ REQUEST in PHP differences

In PHP, $ _ REQUEST, $ _ POST, and $ _ GET are used to accept form data.

I. differences and features between $ _ REQUEST and $ _ POST and $ _ GET

$ _ REQUEST [] uses the $ _ POST [] $ _ GET [] function, but $ _ REQUEST [] is slow. All data submitted through the POST and GET methods can be obtained through the $ _ REQUEST array.

II. differences and features of $ _ POST and $ _ GET

1. GET is to GET data from the server, and POST is to send data to the server.
2. GET is to add the parameter data queue to the URL referred to by the ACTION attribute of the submission form. the values correspond to each field in the form one by one and can be seen in the URL. POST uses the http post mechanism to place fields in the form and their content in the html header and send them to the URL address referred to by the ACTION attribute. You cannot see this process.
3. for form data submitted in GET mode, the server uses $ _ GET ['name'] to obtain the value of the variable. for form data submitted in POST mode, the server uses $ _ POST ['name'] to obtain submitted data. of course, both can obtain form data through $ _ REQUEST ['name. For the form data submitted in the REQUEST method, the server uses $ _ REQUEST ['name'] to obtain the variable value, but this method is rarely used.
4. the data volume transmitted by GET is small and cannot exceed 2 kB. The amount of data transmitted by POST is large, which is generally not restricted by default. However, in theory, it is generally considered that the length cannot exceed KB.
5. Low GET security and high POST security.
6. GET form values can be obtained through _ GET. However, parameters set through the action url cannot be obtained,

AndIs the same, that is, in this case, the GET method will ignore the parameter list behind the action page. The POST form value can be obtained through _ POST, but the parameter set through the action url parameter cannot be obtained through _ POST. Action = test. php? Id = 1: This is the GET method for passing values. you can use $ _ REQUEST and $ _ GET to accept passing values, but you cannot use POST to GET the values, even if the form is submitted in POST mode. When submitting a form, if there are parameters in the action, it is recommended that you only use the POST form method to obtain the data in the form directly through POST. for parameters in the action, child workers GET the data.
We recommend that you use the GET method for data query, and use the POST method for data addition, modification, or deletion.
The request first reads get and then reads post. it also exists, that is, it overwrites the previous variable.

Classic instance:

Echo "get \ n ";
Print_r ($ _ GET );
Echo "post \ n ";
Print_r ($ _ POST );
Echo "request \ n ";
Print_r ($ _ REQUEST );
?>
<Form method = post action = '? A = 1 & B = 2'>
<Input type = text name = a value = 'a'>
<Input type = text name = B value = 'B'>
<Input type = submit value = test>
</Form>

Output result:

Get:
Array
(
[A] => 1
[B] => 2
)
Post:
Array
(
[A] =>
[B] => B
)
Request:
Array
(
[A] =>
[B] => B
)

In fact, in the php configuration file php. there is a configuration item in ini: variables_order = "GPCS". GPCS are GET, POST, Cookie, and Server abbreviations, variables_order = "GPCS" indicates that the parsing sequence of variables in the PHP file is GET, POST, Cookie, and Server.

Differences between $ _ POST $ _ REQUEST: In PHP, $ _ REQUEST, $ _ POST, and $ _ GET are used to accept form data. I. differences and features between $ _ REQUEST and $ _ POST and $ _ GET $ _ REQUEST [] use $ _ POST []...

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.