Get a uniformly selected integer

# Random\Randomizer::getInt

(PHP 8 >= 8.2.0)

Random\Randomizer::getInt — Get a uniformly selected integer

### 说明

public function Random\Randomizer::getInt(int `$min`, int `$max`): int

### 参数

`min`

  The lowest value to be returned.

`max`

  The highest value to be returned.

### 返回值

A uniformly selected integer from the closed interval [`min`, `max`]. Both `min` and `max` are possible return values.

### 错误／异常

- If `max` is less than `min`, a ValueError will be thrown.
- 底层 `Random\Randomizer::$engine` 的 Random\Engine::generate() 方法抛出的任何 Throwable。

### 示例

示例 #1 Random\Randomizer::getInt() example

    <?php
    $r = new \Random\Randomizer();

    // Random integer in range:
    echo $r->getInt(1, 100), "\n";
    ?>

以上示例的输出类似于：

    42

### 参见

- random_int() - 获取生成加密安全、均匀分布的整数
- Random\Randomizer::getFloat() - Get a uniformly selected float

`↑` and `↓` to navigate • `Enter` to select • `Esc` to close • `/` to open