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

29 lines
512 B
PHP
Raw Normal View History

2022-11-17 16:12:51 +00:00
<!DOCTYPE html>
<html>
<head>
<title>Dice</title>
</head>
<body>
<?php
$num_dice = rand(1,10);
2022-11-17 16:36:51 +00:00
if ($num_dice == 1)
echo "<h1>$num_dice dado</h1>";
else
echo "<h1>$num_dice dados</h1>";
2022-11-17 16:12:51 +00:00
$max = -1;
for($i = 0; $i < $num_dice; $i++) {
2022-11-17 16:29:44 +00:00
$roll = rand(1,6);
if($roll > $max)
$max = $roll;
2022-11-17 16:12:51 +00:00
?>
2022-11-17 16:29:44 +00:00
<img src="imgs/<?= $roll ?>.svg" />
2022-11-17 16:12:51 +00:00
<?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>