这是我的代码:
<html>
<title>Game Process</title>
</head>
<body>
<?php
$userguess= $_POST["number"];
$gennumber = rand(0,20);
if ($gennumber > $userguess) {
$result="lost";
echo "You have lost your guess was too low! The number was:".$gennumber;
} elseif ($gennumber == $userguess){
echo "Wow you are extreamly lucky to get ".$gennumber; $result="won";
} else {
echo "You have lost your guess was too high! The number was: ".$gennumber;
$result="lost";
}
?>
这是我试图查看是否$count
等于无的问题,如果它比将其设置为 1。我已经做了一些研究isset
,empty
但我不知道如何使用它们,正如我所说,我是编程的新手!
<?php
$_SESSION['count']=$count;
if (!$count){
} else {
$count = 1;
}
if ($result == "lost"){
echo '<a href="Game.php"><input type="button" value="Have another guess!"/></a>';
$count +1;
echo "<br>your number of guess are: ".$count;
} else {
echo "well done!<br>";
echo "your number of guess are: ".$count;
}
?>
</body>
</html>