← All built-ins / rand()
rand()
rand(...$args): int
Parameters
| Name | Type | Description |
|---|---|---|
| $min | int | lower bound (inclusive)optional |
| $max | int | upper bound (inclusive)optional |
Return value
Pseudo-random integer, in the range when given (not crypto-secure).
Example
$d = rand(1, 6); echo $d >= 1 && $d <= 6 ? "dice-ok" : "bad";
dice-ok