random_int
Get a cryptographically secure, uniformly selected integer
&reftitle.description;
intrandom_int
intmin
intmax
Generates cryptographic random integers that are suitable for use where
unbiased results are critical, such as when shuffling a deck of cards for a
poker game.
&csprng.sources;
&csprng.function.backport;
&reftitle.parameters;
min
The lowest value to be returned; must be
PHP_INT_MIN or greater.
max
The highest value to be returned; must be
PHP_INT_MAX or less.
&reftitle.returnvalues;
A cryptographically secure, uniformly selected integer from the closed interval
[min, max]. Both
min and max are
possible return values.
&reftitle.errors;
&csprng.errors;
If max is less than min, an
ValueError will be thrown.
&reftitle.changelog;
&Version;
&Description;
8.2.0
In case of a CSPRNG failure, this function will now throw a
Random\RandomException. Previously a plain
Exception was thrown.
&reftitle.examples;
random_int example
]]>
&example.outputs.similar;
&reftitle.seealso;
Random\Randomizer::getInt
random_bytes