![]() |
| Rolling Dice in php |
Creating dice game were we want use how to roll a dice randomly. In this example we will use rand function to generate random number between 1 to 6 by supplying argument in rand function. As you may see my tutorial for random number generate in Php for more info on rand function
Code for Creating play game rolling dice in php (Screenshot1):-
<?php
if (isset($_POST['roll'])) {
$rand = rand(1, 6);
echo 'You rolled a '.$rand;
}
?>
<form action="index.php" method="POST">
<input type="Submit" name="roll" value="Roll dice">
</form>
| Screenshot1 |
| Screenshot2 |
| Screenshot3 |


