Last active
October 17, 2019 13:18
-
-
Save stephanBerger/8065a94b56d51a5ad55a12524fa3f893 to your computer and use it in GitHub Desktop.
5. Les conditions en PHP
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$weapons = ['fists', 'whip', 'gun']; | |
$opponentWeapon = $weapons[rand(0,2)]; // Cela permet de choisir une arme de manière aléatoire. | |
if ($opponentWeapon=='gun') { | |
$indyWeapon= $weapons[1]; | |
} elseif ($opponentWeapon=='fists') { | |
$indyWeapon= $weapons[2]; | |
} else { | |
$indyWeapon= $weapons[0]; | |
} | |
echo "Indiana Jones a gagné car avec ".$indyWeapon ." contre " .$opponentWeapon ." .\n"; | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment