PHPmt_rand () function definition and usage
Mt_rand (min, max) returns a random integer using the Mersenne Twister algorithm.
Description
If the optional parameters min and max are not provided, mt_rand () returns a pseudo-random number between 0 and RAND_MAX. For example, if you want a random number between 5 and 15 (including 5 and 15), use mt_rand (5, 15 ).
Many old libc random number generators have some uncertain and unknown features and are very slow. The rand () function of PHP uses the libc random number generator by default. The mt_rand () function is informal to replace it. This function uses known features in Mersenne Twister as a random number generator, which can generate random values at an average speed four times faster than the rand () provided by libc.
Tips and comments
Note: Since PHP 4.2.0, the random number generator is no longer needed to be planted using the srand () or mt_srand () function, which is now automatically completed.
Note: In versions earlier than 3.0.7, max indicates range. In these versions, we need to obtain a random number from 5 to 15, which is the same as the preceding example. The short example is mt_rand (5, 11 ).