PHP development basic tutorial $_GET variable

1. $_GET variable

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

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: The code is as follows

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

大家好,我是 !
今年 岁。

Enter your name and age, click to submit to the current page

Note: When copying to local testing, the address bar The information we entered has been added, the details are as follows

QQ截图20161027110231.png

Note:

  • "?" is preceded by the file address

  • www.phpcourse.com is the virtual domain name I set up myself. If you are interested in how to set up the virtual domain name, you can search online

  • ?name=小方&age=27 is the information submitted by the get method, also called the query string. If you submit it a few times, you will be able to discover its patterns

2. 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: Therefore, 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!