random_int
random_int
Get a cryptographically secure, uniformly selected integer
int **random_int** int $min int $max
Generates a uniformly selected integer between the given minimum and maximum.
The randomness generated by this function is suitable for all applications, including the generation of long-term secrets, such as encryption keys.
minThe lowest value to be returned.
maxThe highest value to be returned.
A cryptographically secure, uniformly selected integer from the closed interval
[, ]. Both
and are
possible return values.
min``max``min``max
- If is less than , a will be thrown.
max``min``ValueError
Voorbeeld: example
<?php
var_dump(random_int(100, 999));
var_dump(random_int(-1000, 0));
?>
int(248)
int(-898)
Random\Randomizer::getInt``random_bytes