(PHP 8 >= 8.2.0)
Random\Randomizer::getInt — Get a uniformly selected integer
public Random\Randomizer::getInt(int $min, int $max): int
minThe lowest value to be returned.
maxThe highest value to be returned.
A uniformly selected integer from the closed interval [min, max]. Both min and max are possible return values.
max is less than min, a ValueError will be thrown. Random\Randomizer::$engine. Example #1 Random\Randomizer::getInt() example
<?php $r = new \Random\Randomizer(); // Random integer in range: echo $r->getInt(1, 100), "\n"; ?>
The above example will output something similar to:
42
© 1997–2025 The PHP Documentation Group
Licensed under the Creative Commons Attribution License v3.0 or later.
https://www.php.net/manual/en/random-randomizer.getint.php