What is the use of php's get variable?

(*-*)浩
Release: 2023-02-26 17:42:02
Original
2578 people have browsed it

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.

What is the use of php's get variable?

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>
Copy after login

The effect is as follows:

What is the use of phps get variable?

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"]; ?> 岁。
Copy after login

After clicking the submit button in code 1, the page will appear as follows

What is the use of phps get variable?

#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!

Related labels:
php
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