Random\Randomizer::getInt
PHP function
Edit on GitHub ✎
(PHP 8 >= 8.2.0)
Get a uniformly selected integer
Description
Random\Randomizer::getInt(int $min, int $max): int
Parameters
minThe lowest value to be returned.
maxThe highest value to be returned.
Return Values
A uniformly selected integer from the closed interval [min, max]. Both min and max are possible return values.
Errors/Exceptions
- If
maxis less thanmin, aValueErrorwill be thrown.
Examples
Random\Randomizer::getInt() example
php
<?php
$r = new \Random\Randomizer();
// Random integer in range:
echo $r->getInt(1, 100), "\n";
?>The above example will output something similar to:
output
42See Also
random_int()Random\Randomizer::getFloat