Player 1: draws a 52
Player 2: draws a 9
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="../styles.css">
<title>PHP: random_int()</title>
</head>
<body>
<h1 class="lesson-h1">PHP: random_int() | Takes 2 Args | (start, finish)</h1>
<form method="get">
<button name="draw" type="submit">Draw Again</button>
</form>
<?php
//This generates random number between 0 and 83
$player1 = random_int(1, 83);
//Runs the same as above. Slightly less typing
$player2 = rand(1, 83);
echo "<hr>";
?>
<p><?php echo "<strong>Player 1: </strong> draws a $player1"; ?></p>
<p><?php echo "<strong>Player 2: </strong> draws a $player2"; ?></p>
<h2>
<?php
if($player1 > $player2){
echo "Player 1 has drawn a $player1 and is the winner!!! 😆";
} else if($player1 < $player2){
echo "Player 2 has drawn a $player2 and is the winner!!! 🤩";
}else {
echo "Both players have drawn a $player1 and this has been declared a tie!!! 😎";
}
?>
</h2>
<hr>
<?php
include('../show_code.php');
show_code('index.php');
?>
</body>
</html>