Home >Backend Development >PHP Problem >What is the use of php's get variable?
WeWhen doing web page interaction design, we usually use the get variable method in PHP to obtain the data in the form, so as to implement various web page dynamic queries or requests.
For friends who have a little HTML foundation, they should all know that there are two submission methods in the HTML form, namely get and post, but for novices, To put it bluntly, perhaps this knowledge point is still a bit vague.
Then this article will mainly give you a detailed introduction to the get method, that is, the specific method and use of PHP to obtain form form data through get variables
The following To bring you a specific code example:
form form code example (form get submission)
<head> <meta charset="utf-8"> <title>form表单get方法示例</title> </head> <body> <form action="/test/test.php" method="get" > <form action="test.php" method="get"> 名字: <input type="text" name="fname"><br> 年龄: <input type="text" name="age"><br> <input type="submit" value="提交"> </form> </form> </body> </html>
The effect is as follows:
test.php code (php receives get data)
<?php header("content-type:text/html;charset=utf-8"); //设置编码 ?> 欢迎 <?php echo $_GET["fname"]; ?>!<br> 你的年龄是 <?php echo $_GET["age"]; ?> 岁。
After clicking the submit button in code 1, the page will appear as follows
#You can pay attention here. What are the characteristics of the links in the browser address bar? It is not difficult to find that the information sent from the form with the GET method will be displayed in the address bar and is visible to anyone. That is, when using method="get" in an HTML form, all variable names and values will be displayed in the URL.
The above is the detailed content of What is the use of php's get variable?. For more information, please follow other related articles on the PHP Chinese website!