Tuesday, 15 October 2013

Creating Play Game Rolling Dice

Creating Play Game Rolling Dice
Creating dice game were we want use how to roll a dice randomly. In this example we will use rand function to generate randomnumber between 1 to 6 by supplying argument in rand function. As you may see my tutorial for random number generate for more infoon rand function
Creating play game rolling dice in php
Creating play game rolling dice in php (Screenshot1)
Code for Creating play game rolling dice in php
1
2
3
4
5
6
7
8
9
10
11
12
<?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>
Output (Screenshot2 , Screenshot3):-
Creating play game rolling dice in php
Creating play game rolling dice in php (Screenshot2)
Creating play game rolling dice in php
Creating play game rolling dice in php (Screenshot3)
As you can see playing rolling dice script in php. We created form with submit button when ever user clicks submit button with willgenerate random number with rand function with two argument such as 1 which is lower limit it will not show less then one numberand upper limit is 6 it will not echo out more then 6 number value as you seen dice it only contains number 1 to 6.

Read More Extra Tutorials

No comments:

Post a Comment