fork download
  1. <?php
  2.  
  3.  
  4. $myDice1 = mt_rand(1,6);
  5. $myDice2 = mt_rand(1,6);
  6.  
  7. $compDice1 = mt_rand(1,6);
  8. $compDice2 = mt_rand(1,6);
  9.  
  10. echo "You have $myDice1 and $myDice2, computer have $compDice1 and $compDice2 \n";
  11.  
  12. $sumMyDice = ($myDice1 + $myDice2);
  13. $sumCompDice = ($compDice1 + $compDice2);
  14.  
  15. if (($myDice1 == $myDice2) && ($compDice1 == $compDice2)){
  16. echo "Two doubles. Yay!";
  17. exit();
  18. }
  19. elseif ($sumMyDice > $sumCompDice){
  20. echo "I win!";
  21. }
  22. elseif ($sumMyDice < $sumCompDice){
  23. echo "Comp win!";
  24. }
  25. // your code goes here
Success #stdin #stdout 0.03s 52432KB
stdin
Standard input is empty
stdout
You have 5 and 4, computer have 2 and 5 
I win!