mt_srand
Function • Params changed in PHP 8.3
Seeds the Mersenne Twister Random Number Generator.
mt_srand Function synopsis
mt_srand(?int $seed = null, int $mode = MT_RAND_MT19937): void
Parameters
$seed
OptionalType?intDefault valuenull
Fills the state with values generated with a linear congruential generator
that was seeded with $seed interpreted as an unsigned
32 bit integer.
$mode
OptionalTypeintDefault valueMT_RAND_MT19937
Use one of the following constants to specify the implementation of the algorithm to use.
$mode accepts one of the following constant values:
Return value
The mt_srand function is a void function; it does not return any values.
Changes to the mt_srand Function
PHP 8.3
- Parameter type changed for parameter #1 (
$seed):intto?int - Parameter default value changed for position #1 (
$seed):<default>tonull
- mt_srand(int $seed = <default>, int $mode = MT_RAND_MT19937): void
+ mt_srand(?int $seed = null, int $mode = MT_RAND_MT19937): void PHP 8.2
PHP 8.1
- Parameter default value changed for position #1 (
$seed):0to<default>
- mt_srand(int $seed = 0, int $mode = MT_RAND_MT19937): void
+ mt_srand(int $seed = <default>, int $mode = MT_RAND_MT19937): void PHP 8.0
- Return type added:
void - Parameter type added for parameter #1 (
$seed):int - Parameter default value added for position #1 (
$seed):0 - Parameter type added for parameter #2 (
$mode):int - Parameter default value added for position #2 (
$mode):MT_RAND_MT19937
- mt_srand($seed, $mode)
+ mt_srand(int $seed = 0, int $mode = MT_RAND_MT19937): void PHP 7.1
- Optional parameter added - #2:
$mode
- mt_srand($seed)
+ mt_srand($seed, $mode) mt_srand Function Availability
mt_srand Function Availability| PHP Version | Availability |
|---|---|
| PHP 8.6Upcoming Release | Yes |
| PHP 8.5Supported (Latest) | Yes |
| PHP 8.4Supported | Yes |
| PHP 8.3Security-Fixes Only | Yes |
| PHP 8.2Security-Fixes Only | Yes |
| PHP 8.1Unsupported | Yes |
| PHP 8.0Unsupported | Yes |
| PHP 7.4Unsupported | Yes |
| PHP 7.3Unsupported | Yes |
| PHP 7.2Unsupported | Yes |
| PHP 7.1Unsupported | Yes |
| PHP 7.0Unsupported | Yes |
| PHP 5.6Unsupported | Yes |
| PHP 5.5Unsupported | Yes |
| PHP 5.4Unsupported | Yes |
| PHP 5.3Unsupported | Yes |