Home >Backend Development >PHP Tutorial >PHP simulation dice implementation code
This article mainly shares with you the implementation code of PHP simulated dice, mainly in the form of code, hoping to help everyone.
<?PHP $sum=0; $num=rand(1,6); $sum=$sum+$num;//前进步长 while ($num==6){ $num=rand(1,6);//模拟骰子的投掷 $sum=$sum+$num;//作为前进步长 }; echo "while例子执行完毕,前进:".$sum."<br />"; $sum=0; do{ $num=rand(1,6); $sum=$sum+$num; }while ($num==6); echo "do...while 的例子执行完毕,前进:".$sum."<br />";
css, js dice lottery source code
The above is the detailed content of PHP simulation dice implementation code. For more information, please follow other related articles on the PHP Chinese website!