← All built-ins / random_int()
random_int()
random_int(...$args): int
Parameters
| Name | Type | Description |
|---|---|---|
| $min | int | lower bound (inclusive) |
| $max | int | upper bound (inclusive) |
Return value
Cryptographically secure random integer in [$min, $max].
Example
$k = random_int(1000, 9999); echo $k >= 1000 && $k <= 9999 ? "pin-ok" : "bad";
pin-ok