CakeFest 2024: The Official CakePHP Conference

mt_getrandmax

(PHP 4, PHP 5, PHP 7, PHP 8)

mt_getrandmax显示随机数的最大可能值

说明

mt_getrandmax(): int

返回调用 mt_rand() 所能返回的最大的随机数。

参数

此函数没有参数。

返回值

返回不带参数调用 mt_rand() 时获取到的最大随机值,这可用于 max 参数而不是放大结果的最大值(更少的随机)。

参见

  • mt_rand() - 通过梅森旋转(Mersenne Twister)随机数生成器生成随机值
  • mt_srand() - 播下一个更好的随机数发生器种子
  • getrandmax() - 显示随机数最大的可能值

add a note

User Contributed Notes 1 note

up
25
bishop at php dot net
8 years ago
The upper-bound of this value is platform-independent. PHP implements the 32-bit version of the Mersenne Twister ("mt"), so the maximum possible value is 2**31 - 1 (2147483647).
To Top