php8.5
Home/ Manual/ random / functions/ srand

srand

PHP function Edit on GitHub ✎

(PHP 4, PHP 5, PHP 7, PHP 8)

Seed the random number generator

Description

srand(int|null $seed = null, int $mode = MT_RAND_MT19937): void

Seeds the random number generator with seed or with a random value if no seed is given.

Randomseed Mt19937-tiny-seed

Note

As of PHP 7.1.0, srand() has been made an alias of mt_srand().

Parameters

seed

Fills the state with values generated with a linear congruential generator that was seeded with seed interpreted as an unsigned 32 bit integer.

If seed is omitted or null, a random unsigned 32-bit integer will be used.

Return Values

Void

Changelog

VersionDescription
8.3.0seed is now nullable.
7.1.0srand()has been made an alias of mt_srand().

See Also

Source: reference/random/functions/srand.xml · from the official PHP manual (php/doc-en)