Home > Backend Development > PHP Problem > What is the usage of php get

What is the usage of php get

藏色散人
Release: 2023-03-03 10:48:01
Original
4648 people have browsed it

php get refers to the "$_GET" variable, which is an array whose content is the variable name and value sent by the HTTP GET method. Its function is to collect data from the form of "method="get"" Value, its syntax is like "method="get"".

What is the usage of php get

Recommended: "PHP Tutorial"

$_GET Variable

## The #$_GET variable is used to collect values ​​from the form with method="get". Intuitively, it is the parameters that can be seen in the browser. For example, when I search for "wordpress" on Baidu, the URL I request is http: //www.baidu.com/s?ie=utf-8&bs=wordpress&f=8&rsv_bp=1&wd=wordpress&inputT=0, then the parameters after '?' can be obtained with $_GET, and each parameter is separated by '&' Matching.

$_GET variable is an array containing variable names and values ​​sent by the HTTP GET method.

The information sent from the form with the GET method is visible to anyone (will be displayed in the browser's address bar), and there is a limit on the amount of information sent (up to 100 characters), Therefore, the length of the parameters is not infinite, but it can basically meet our requirements.

Example

<form action="hello.php" method="get">
Name: <input type="text" name="name" />
Age: <input type="text" name="age" />
<input type="submit" />
</form>
Copy after login

When the user clicks the submit button, the URL sent will look like this:

  http://www.w3school.com.cn/welcome.php?name=Peter&age=37
Copy after login

The "hello.php" file can now get the form through the $_GET variable data (please note that the name of the form field will automatically become the ID key in the $_GET array)

  Welcome <?php echo $_GET["name"]; ?>.<br />
You are <?php echo $_GET["age"]; ?> years old!
Copy after login

If you enter Mike in the name form box and enter 23 in the age form box, then it will be displayed The result is like this

  Welcome Mike 
  You are 23 years old!
Copy after login

The above is the detailed content of What is the usage of php get. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template