[면책 조항 : PHP에 익숙하지 않고 방금 배우기 때문에 불쾌감을 느끼지 마십시오. 배워야 할 때 학습 과정을 방해합니다. 감사합니다. ]PHP가 너무 높거나 너무 낮게 반복 할 수 없음
아래 코드는 실행되는데 문제는 숫자가 너무 높거나 낮을 때 사용자에게 알려주지 않는다는 것입니다. 잘못된 것이지만 오류는 볼 수 없습니까?
<?php
//Starts our php document
if (!$number)
//if we have already defined number and started the game, this does not run
{
Echo"Please Choose a Number 1-100 <p>";
//gives the user instructions
$number = rand (1,100) ;
//creates number
}
else {
//this runs if the game is already in progress
if ($Num >$number)
{
Echo "Your number, $Num, is too high. Please try again<p>";
}
//if the number they guessed is bigger than number, lets user know, guess was high
elseif ($Num == $number)
{
Echo "Congratulations you have won!<p>";
//if the number they guessed was correct it lets them know they won
Echo "To play again, please Choose a Number 1-100 <p>";
$number = rand (1,100) ;
//it then starts the game again by choosing a new value for $number that they can guess
}
else
{
Echo "Your number, $Num, is too low. Please try again<p>";
}
//if the answer is neither correct or to high, it tells them it is too low
}
?>
<form action = "<?php Echo $_SERVER[’PHP_SELF’]; ?>" method = "post"> <p>
<!--this sends the form back to the same page we are on-->
Your Guess:<input name="Num" />
<input type = "submit" name = "Guess"/> <p>
<!--Allows the user to input their guess-->
<input type = "hidden" name = "number" value=<?php Echo $number ?>>
<!--keeps passing along the number value to keep it consistent till it is guessed-->
</form>
</body>
</html>
나는 선제에 대한 +1주고있어 * 제발 화를 내게하지 마세요 * 그게 * 정말 * 미소 짓게 =) –