Since: 8.2

final class Mt19937 implements Engine (View source)

Methods

__construct(int|null $seed = null, int $mode = MT_RAND_MT19937)

Constructs a new Mt19937 engine

string
generate()

Generates randomness

array
__serialize()

No description

void
__unserialize(array $data)

No description

array
__debugInfo()

No description

Details

__construct(int|null $seed = null, int $mode = MT_RAND_MT19937)

Constructs a new Mt19937 engine

Parameters

int|null $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.

int $mode

Use one of the following constants to specify the implementation of the algorithm to use. MT_RAND_MT19937: The correct Mt19937 implementation. MT_RAND_PHP: An incorrect implementation for backwards compatibility with mt_srand prior to PHP 7.1.0. This feature has been DEPRECATED as of PHP 8.3.0. Relying on this feature is highly discouraged.

string generate()

Generates randomness

Returns randomness and advances the algorithm’s state by one step.

Return Value

string

A non-empty string containing random bytes. The Random\Randomizer works with unsigned 64 bit integers internally. If the returned string contains more than 64 bit (8 byte) of randomness the exceeding bytes will be ignored. Other applications may be able to process more than 64 bit at once.

array __serialize()

No description

Return Value

array

void __unserialize(array $data)

No description

Parameters

array $data

Return Value

void

array __debugInfo()

No description

Return Value

array