PHP simulation dice implementation code

小云云
Release: 2023-03-22 18:52:02
Original
2558 people have browsed it

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  />";
Copy after login
Related recommendations:

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!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template