Play Rock Paper Scissors Online - Free Game
Rock Paper Scissors
// Map the generated number to the array of choices
$choices = array('rock', 'paper', 'scissors');
$computerChoice = $choices[$computerChoice];
// Compare the user's choice to the computer's choice
if ($_POST['choice'] == $computerChoice) {
echo '<h2>It's a tie!</h2>';
} else if ($_POST['choice'] == 'rock' && $computerChoice == 'scissors') {
echo '<h2>You win!</h2>';
} else if ($_POST['choice'] == 'rock' && $computerChoice == 'paper') {
echo '<h2>You lose!</h2>';
} else if ($_POST['choice'] == 'paper' && $computerChoice == 'rock') {
echo '<h2>You win!</h2>';
} else if ($_POST['choice'] == 'paper' && $computerChoice == 'scissors') {
echo '<h2>You lose!</h2>';
} else if ($_POST['choice'] == 'scissors' && $computerChoice == 'rock') {
echo '<h2>You lose!</h2>';
} else if ($_POST['choice'] == 'scissors' && $computerChoice == 'paper') {
echo '<h2>You win!</h2>';
}
}
?>
原文地址: https://www.cveoy.top/t/topic/lmn1 著作权归作者所有。请勿转载和采集!