亚洲国产日韩欧美一区二区三区,精品亚洲国产成人av在线,国产99视频精品免视看7,99国产精品久久久久久久成人热,欧美日韩亚洲国产综合乱

PHP $_GET variable

We already knew when we were studying that the $_GET variable is used to collect values ??from the form with method="get".

$_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 anyone (will be displayed in the browser's address bar), and there is a limit on the amount of information sent.

Let’s use an example to illustrate:

Example

<html>
 <head>
     <meta charset="utf-8">
     <title>php中文網(wǎng)(php.cn)</title>
 </head>
 <body>
 
 <form action="php_get.php" method="get">
     名字: <input type="text" name="name"><br>
     性別:<input type="radio" name="sex" value="男" checked>男
     <input type="radio" name="sex" value="女">女<br>
     年齡: <input type="text" name="age"><br>
     <input type="submit" value="提交">
 </form>
 
 </body>
 </html>

Submit to php_get.php page

<?php
 header("Content-type:text/html;charset=utf-8");    //設(shè)置編碼
 echo "你的姓名是:" .$_GET['name'] ."<br/>";
 echo "你的性別是:"  .$_GET['sex']."<br/>";
 echo "你的年齡是:".$_GET['age'];
 ?>

Program running result:

2.png

We found that the values ??we filled in the form are all displayed in the Url column

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
||
<html> <head> <meta charset="utf-8"> <title>php中文網(wǎng)(php.cn)</title> </head> <body> <form action="php_get.php" method="get"> 名字: <input type="text" name="name"><br> 性別:<input type="radio" name="sex" value="男" checked>男 <input type="radio" name="sex" value="女">女<br> 年齡: <input type="text" name="age"><br> <input type="submit" value="提交"> </form> </body> </html>
submitReset Code