mt_srand

FunctionParams changed in PHP 8.3

Seeds the Mersenne Twister Random Number Generator.

PHP 5
PHP 7
PHP 8.0
Improved
PHP 8.1
Improved
PHP 8.2
Changed
PHP 8.3
Improved
PHP 8.4
PHP 8.5
PHP 8.6

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): int to ?int
  • Parameter default value changed for position #1 ($seed): <default> to null
- 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): 0 to <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

PHP VersionAvailability
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