PHP $_GET variable

PHP $_GET Variable

In PHP, the predefined $_GET variable is used to collect values from the form with method="get".

$_GET variable

The predefined $_GET variable is used to collect forms from method="get" value in .

The information sent from a form with the GET method is visible to everyone (will be displayed in the browser's address bar), and there is a limit on the amount of information sent.

Example

form.html file code is as follows:

   php中文网(php.cn) 
名字: 年龄:

When the user clicks the "Submit" button, the URL sent to the server is as follows:

//m.sbmmt.com/welcome.php?fname=php&age=3

"welcome.php" file can now collect form data through the $_GET variable (please note that the form field The name will automatically become a key in the $_GET array):

Welcome!

Your age is Years old.

#When to use method="get"?

When using method="get" in an HTML form, all variable names and values will be displayed in the URL.

Note: So this method should not be used when sending passwords or other sensitive information!

However, because the variable appears in the URL, it is possible to bookmark the page. In some cases this is useful.

Note: The HTTP GET method is not suitable for large variable values. Its value cannot exceed 2000 characters.


Continuing Learning
||
php中文网(php.cn)
名字: 年龄:
submit Reset Code
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!