我正在尝试将我的剪刀石头布的php游戏添加到Web并从页面调用函数,我们必须使用超全局$ _REQUEST,但是无论我尝试什么,都会遇到以下错误:
注意:未定义索引:
请问如何定义?我是这个的新手。
我已经尝试了各种方法。...到目前为止,这是我的代码.....我还希望能够在用户选择.....谢谢之前停止浏览计算机的选择。 / p>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>ROCK,PAPER,SCISSORS</title>
</head>
<body>
<h1>Please make your selection</h1>
<form action="Test.php"method="POST">
<input type="radio" name="choice" value="0"/>Rock<br />
<input type="radio" name="choice" value="1"/>Paper<br />
<input type="radio" name="choice" value="2"/>Scissors<br
/>
<input type="submit" value="Submit"required />
</form>
if (isset($_REQUEST["choice"])) {
$userChoice = $_REQUEST["choice"];
}
echo"$userChoice"; //willbe removed when complete, just adding to test that it works
//computer generates a random value 0,1,2 & converts to R P or S
echo "\nComputer is now making its selection....\n";
//$options = ('Rock=0, Paper=1, Scissors=2');
$output = (rand(0,2) );
echo $output;
if ($output===0)
{
echo "\nComputer Selected Rock\n";
}
elseif ($output===1)
{
echo "\nComputer Selected Paper\n";
}
elseif ($output===2)
{
echo "\nComputer Selected Scissors\n";
}