← All built-ins / srand()

srand()

srand(...$args): void

Parameters

NameTypeDescription
$seedintseed value

Return value

Seeds rand() for reproducible sequences.

Example

srand(42);
$a = rand(0, 1000);
srand(42);
$b = rand(0, 1000);
echo $a == $b ? "reproducible" : "random";
reproducible

See also

rand()mt_srand()