这是我的html页面:
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Hello and welcome to my site</title>
</head>
<body>
<p>are these 2 numbers equal? type yes or no in the box</p>
<p2>one</p2> and eight
<form action="welcome_get.php" method="get">
Answer: <input type="text" name="name"><br>
<input type="submit">
</form>
</body>
</html>
这是我的新php页面,包含先前的答案,我有新的错误
<html>
<body>
<?php
var_dump($_GET['name']);
$answer = $_GET['name'];
$saying = "congratulations";
if ($answer == "yes"){
echo $saying;
}
?>
</body>
</html>
新错误是指我的php页面welcome_get.php
答案 0 :(得分:3)
var_dump($_GET['name']);
此外,要查看所有可用的GET参数:
var_dump($_GET)
分配给新变量:
if(!empty($_GET['name'])){
$answer = $_GET['name'];
if($answer == 'something'){
// do something
}
}
答案 1 :(得分:1)
您可以使用isset函数检查$ _GET [&#39; var&#39;]是否已设置
if(isset($_GET['name'])){ $answer = $_GET['name']; $saying = "congratulations"; if ($answer == "yes"){ echo $saying; } }