作者Palatino (安安)
看板PHP
标题[请益] 不太懂srand是干麻用的..
时间Sun Feb 21 03:27:43 2016
如题,最近在学PHP,看到一行程式
srand((double)microtime() * 1000000);
来源:
http://goo.gl/uOhAer
我就上网查了一下它是什麽,
srand — Seed the random number generator
Seeds the random number generator with seed or with a
random value if no seed is given.
看了中文和英文,都不太懂它是在干麻⊙⊙
只知道目前的版本好像可以自动完成什麽的
它是会随机产生乱数吗?
新手上路,还请多多指教~感激感激<(__ __)>
--
※ 发信站: 批踢踢实业坊(ptt.cc), 来自: 36.224.207.236
※ 文章网址: https://webptt.com/cn.aspx?n=bbs/PHP/M.1455996466.A.EEB.html
※ 编辑: Palatino (36.224.207.236), 02/21/2016 03:34:47
1F:推 LPH66: 电脑的乱数都是计算出来的, 只是"看起来"有一点乱这样 02/21 06:12
2F:→ LPH66: 既然是计算就要有一个起点, srand 就是设定起点用的 02/21 06:12
3F:→ LPH66: 你可以把它看成乱数表里的位置 02/21 06:12
4F:→ LPH66: 然後用 microtime() 就是使用现在时间当做起始点 02/21 06:13
5F:→ LPH66: 这样每次执行时都会是个不一样的起点 02/21 06:13
6F:→ Palatino: 谢谢LPH大大 ‧☆,:*:‧\( ̄▽ ̄)/‧:*‧°☆* 02/21 19:18