About the $ _ GET array in PHP

Source: Internet
Author: User

In the development process, GET and POST are everywhere like souls. The $ _ GET variable is an array with the variable name and value sent by the http get method.

The $ _ GET variable is used to collect the values in the form from method = "get. The information sent from a form with the GET method is visible to anyone (displayed in the address bar of the browser), and the amount of information sent is limited (up to 100 characters ).

When $ _ GET is used, all variable names and values are displayed in the URL. Therefore, this method should not be used when sending passwords or other sensitive information. However, because the variables are displayed in the URL, you can add the page to favorites. In some cases, this is useful.

In general, the URL will use the & operator to separate multiple variables. Of course, you can also set it as another symbol. Use the ',' symbol as the variable separator, which can be implemented in two ways:

1. Modify php. ini

——; list of separator(s) used by php to parse input urls into variables.; default is "&". ; note: every character in this directive is considered as separator!arg_separator.input = ";,"————

2. Write your own interpretation syntax

List ($ key, $ value) =$ _ get; // break down the get variable $ tmp = explode (",", $ value); // split the data

The advantage of this usage is that others cannot know who is using the value you passed, and you need to understand the usage of each value.

For http://www.bkjia.com/test.php? Website = bkjia.com is the same as method 2 in the get method. You need to convert the key into value for decomposition. I think this method is better than the previous method, it is more convenient.

$value = key($_GET);$tmp = explode(",", $value);print_r($tmp);

You should have obtained the data.

You can use the following method to traverse the $ _ GET variable with multiple elements:

while( list($key, $value) = each($_GET) ){echo "Key: $key; Value: $value <br />";}

You can also use:

foreach ($_GET as $key => $value) {    echo "Key: $key; Value: $value <br />n";}

For $ _ REQUEST variables, PHP's $ _ REQUEST variables include $ _ GET, $ _ POST, and $ _ COOKIE content. The $ _ REQUEST variable of PHP can be used to obtain the results of form data sent through the GET and POST methods.

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.