Home  >  Article  >  Backend Development  >  随机数输出有关问题

随机数输出有关问题

WBOY
WBOYOriginal
2016-06-13 13:06:47738browse

随机数输出问题
$randnumber=rand(1,4);
switch ($randnumber)
{
case 1:
echo "1";
break;
case 2:
echo "2";
break;
case 3:
echo "3";
break;
case 4:
echo "4";
break;
default:
 echo "0";

}

请教,以上的输出结果在1-4之间变幻,为什么不是一个固定值呢


------解决方案--------------------
固定了就不是随机数了
------解决方案--------------------
你想干嘛呢?

探讨
$randnumber=rand(1,4);
switch ($randnumber)
{
case 1:
echo "1";
break;
case 2:
echo "2";
break;
case 3:
echo "3";
break;
case 4:
echo "4";
break;
default:
echo "0";

}

请教,以上的输出结果……

------解决方案--------------------
你每次刷新就会变化
Statement:
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