• 首页
  • vue
  • TypeScript
  • JavaScript
  • scss
  • css3
  • html5
  • php
  • MySQL
  • redis
  • jQuery
  • gmp_random_range()

    (PHP 5 >= 5.6.3, PHP 7)

    Random number

    说明

    gmp_random_range(GMP$min, GMP$max): GMP

    Generate a random number. The number will be between$minand$max.

    $minand$maxcan both be negative but$minmust 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.

    范例

    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