PHP-Seite simuliert einen Würfelwurf mit random_int und zeigt das Ergebnis klar auf einer einfachen HTML-Seite ohne externe Bibliotheken an.
<?php
// Simulation eines Wurfs mit einem 6-seitigen Würfel
// Erzeugt eine Zufallszahl zwischen 1 und 6 und zeigt sie auf einer HTML-Seite an
// Funktion zur Simulation des Würfelwurfs
function lanciaDado() {
// random_int wird aus Sicherheits- und Zufallsgründen gegenüber rand() bevorzugt
return random_int(1, 6);
}
// Führe den Würfelwurf aus
$risultato = lanciaDado();
?>
<!DOCTYPE html>
<html lang="it">
<head>
<meta charset="UTF-8">
<title>Würfelwurf</title>
<style>
body {
font-family: Arial, sans-serif;
background-color: #f0f0f0;
text-align: center;
padding-top: 50px;
}
.dado {
font-size: 72px;
color: #333;
margin-bottom: 20px;
}
.messaggio {
font-size: 24px;
color: #555;
}
.bottone {
margin-top: 30px;
padding: 10px 20px;
font-size: 18px;
cursor: pointer;
background-color: #007BFF;
border: none;
color: white;
border-radius: 5px;
}
.bottone:hover {
background-color: #0056b3;
}
</style>
</head>
<body>
<div class="dado">🎲 <?php echo $risultato; ?></div>
<div class="messaggio">Du hast eine <?php echo $risultato; ?> gewürfelt!</div>
<!-- Button zum erneuten Würfeln -->
<form method="get">
<button type="submit" class="bottone">Noch einmal würfeln</button>
</form>
</body>
</html>PHP 7.0+ installiert und auf einem Webserver (Apache/Nginx) konfiguriert
Webbrowser zum Anzeigen der Seite
ABHÄNGIGKEITEN: keine externen Bibliotheken erforderlich
KONFIG: keine externe Konfiguration erforderlich