English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية
The mt_rand() function is used to generate random numbers. It generates numbers using the Mersenne Twister algorithm.
Note-This function is faster thanrand()
Method is faster
mt_rand() or mt_rand(min, max)
min-Default is 0. The minimum number to return.
max-The maximum number to return.
The mt_rand() function returns a random integer between min (or 0) and max. If max < min, it returns FALSE.
<?php echo mt_rand(100, 200); ?>
Output result
144
Let's look at another example-
<?php echo mt_rand(); ?>
Output result
132850920