ceu-notes/2/IAW/exercises/php/dice.php

27 lines
494 B
PHP

<!DOCTYPE html>
<html>
<head>
<title>Dice</title>
</head>
<body>
<?php
$num_dice = rand(1,10);
?>
<h1><?= $num_dice ?> dados</h1>
<?php
$rolls = [];
$max = -1;
for($i = 0; $i < $num_dice; $i++) {
$rolls[$i] = rand(1,6);
if($rolls[$i] > $max)
$max = $rolls[$i];
?>
<img src="imgs/<?= $rolls[$i] ?>.svg" />
<?php
}
?>
<p>El valor más grande obtenido es <b><?= $max ?></b>.</p>
<p>Última modificación de esta página: <?= date('Y-m-d', filemtime(__FILE__)) ?>
</body>
</html>