mt_rand
mt_rand
Generate a random value via the Mersenne Twister Random Number Generator
int **mt_rand**
int **mt_rand** int $min int $max
Many random number generators of older libcs
have dubious or unknown characteristics and are slow.
The function is a drop-in replacement
for the older . It uses a random
number generator with known characteristics using the
, which
will produce random numbers four times faster than what the average
libc rand() provides.
mt_rand``randMersenne Twister
If called without the optional ,
arguments
returns a pseudo-random value between 0 and
. If you want a random number
between 5 and 15 (inclusive), for example, use .
min``max``mt_rand``mt_getrandmax``mt_rand(5, 15)
minOptional lowest value to be returned (default: 0)
max
Optional highest value to be returned (default: )
mt_getrandmax
A random integer value between (or 0)
and (or , inclusive).
min``max``mt_getrandmax
-
If is less than , a will be thrown.
max``min``ValueErrorVoorbeeld: example
<?php
echo mt_rand(), "\n";
echo mt_rand(), "\n";
echo mt_rand(5, 15), "\n";
?>
1604716014
1478613278
6
Waarschuwing: > range must be within the range . i.e. ( - ) <= Otherwise, may return poorer random numbers than it should.
min``max``mt_getrandmax``max``min``mt_getrandmax``mt_rand
mt_srand``mt_getrandmax``random_int``random_bytes