1. $ _ GET is used to obtain data in the form of get in the table method.
2. $ _ GET url. php? I = 12 data,
The above is the data we often use get to obtain values,
Instance 1: Get form data
| The code is as follows: |
Copy code |
|
<Form action = "get. php" method = "get">
Name: <input type = "text" name = "username"/>
<Input type = "submit" value = "OK"/>
</Form> |
Get. php
Assume that I entered www.111cn.net
| The code is as follows: |
Copy code |
|
You are <? Php echo $ _ GET ["username"]?>. |
The output result is
| The code is as follows: |
Copy code |
|
You are www.111cn.net |
What is the url style when we click to submit?
| The code is as follows: |
Copy code |
|
Get. php? Username = www.111cn.net |
This form is the second method we are talking about to obtain data. Next we will look at using a for reference.
/A. php? Value = my
A. php
| The code is as follows: |
Copy code |
|
The value of value is <? Php echo $ _ GET ["value"];?>. <Br/> |
The output result is
| The code is as follows: |
Copy code |
|
The value of value is my. |
This seems to be no different from form's method = get. Haha, the article is here.
There is also a way to get, that is, the form of direct $ _ GET, and view the instance.
| The code is as follows: |
Copy code |
|
<Form action = "checkbox. php" method = "get">
<Input type = "checkbox" name = "fruit []" value = "Apple"> Apple </input> <br/>
<Input type = "checkbox" name = "fruit []" value = "Orange"> Orange </input> <br/>
<Input type = "checkbox" name = "fruit []" value = "Mango"> Mango </input> <br/>
<Input type = "submit" value = "OK"> |
Checkbox. Php file code
| The code is as follows: |
Copy code |
|
<? Phpecho count ($ _ GET ["fruit"]), "<br/> ";
Foreach ($ _ GET ["fruit"] as $ value)
{Echo $ value, "<br/> ";
}?> |
The output result is
If you choose Orange and Mango
Note that $ _ GET is not suitable for obtaining a large amount of data. The length value cannot exceed 100 characters.
Original site Original tutorial reprint must be noted Source: http://www.111cn.nethttp: // www.111cn.net/phper/php.html