mt_rand說明int mt_rand ( [int min, int max] )很多老的 libc 的隨機數發生器具有一些不確定和不明的特性而且很慢。PHP 的 rand() 函數預設使用 libc 隨機數發生器。mt_rand() 函數是非正式用來置換它的。該函數用了 Mersenne Twister 中已知的特性作為隨機數發生器,它可以產生隨機數值的平均速度比 libc 提供的 rand() 快四倍。 若果沒有提供可選參數 min 和 max,mt_rand() 返回 0 到 RAND_MAX 之間的偽隨機數。例如想要 5 到 15(內含 5 和 15)之間的隨機數,用 mt_rand(5, 15)。
參見 mt_srand(),mt_getrandmax() 和 rand()。 | |||