©
本文档使用 PHP中文网手册 发布
(PHP 5, PHP 7 >= 5.6.3)
gmp_random_range — Random number
$min
, GMP $max
)
Generate a random number. The number will be between
min
and max
.
min
and max
can both be negative but min
must always be less than max
.
min
A GMP number representing the lower bound for the random number
max
A GMP number representing the upper bound for the random number
A random GMP number.
Example #1 gmp_random_range() example
<?php
$rand1 = gmp_random_range ( 0 , 100 ); // random number between 0 and 100
$rand2 = gmp_random_range (- 100 , - 10 ); // random number between -100 and -10
echo gmp_strval ( $rand1 ) . "\n" ;
echo gmp_strval ( $rand2 ) . "\n" ;
?>
以上例程会输出:
42 -67