小白教程
所有教程
关于
Search
172.69.7.197
172.69.7.197
参数设置
贡献
退出
操作
编辑
移动
保护
信息
历史
删除
查看“Func math mt rand”的源代码
本页内容
上一节:
Func_math_mt_getrandmax
下一节:
Func_math_mt_srand
因为以下原因,您没有权限编辑本页:
您请求的操作仅限属于该用户组的用户执行:
用户
您可以查看和复制此页面的源代码。
{{DISPLAYTITLE:mt_rand()}}[[Category:PHP Math 数学函数参考手册|35]] = PHP mt_rand() 函数 = [[:Category:PHP Math 数学函数参考手册]] 生成随机数: <sample title="" desc="" lang="php" hererun="1"> <?php echo(mt_rand() . "<br>"); echo(mt_rand() . "<br>"); echo(mt_rand(10,100)); ?> </sample> == 定义和用法 == mt_rand() 函数使用 Mersenne Twister 算法生成随机整数。 '''提示:'''该函数是产生随机值的更好选择,返回结果的速度是 [[func math rand|rand()]] 函数的 4 倍。 '''提示:'''如果您想要一个介于 10 和 100 之间(包括 10 和 100)的随机整数,请使用 mt_rand (10,100)。 == 语法 == <pre> mt_rand(); or mt_rand(min,max);</pre> {| class="table table-striped table-hover" ! 参数 ! 描述 |- | min | 可选。规定返回的最小数。默认是 0。 |- | max | 可选。规定返回的最大数。默认是 [[func math mt getrandmax|mt_getrandmax()]]。 |} == 技术细节 == {| class="table table-striped table-hover" | 返回值: | 介于 min(或 0)与 max(或 mt_getrandmax())之间(包括边界值)的随机整数。如果 max < min 则返回 FALSE。 |- | 返回类型: | Integer |- | PHP 版本: | 4+ |- | PHP 更新日志: | PHP 4.2.0:随机数生成器自动播种。PHP 5.3.4:如果 max < min 则报告一个 E_WARNING 并返回 FALSE。 |} [[:Category:PHP Math 数学函数参考手册]]
返回至“
Func math mt rand
”。
上一节:
Func_math_mt_getrandmax
下一节:
Func_math_mt_srand