Random\Randomizer::__serialize

(PHP 8 >= 8.2.0)

Random\Randomizer::__serializeSerializes the Randomizer object

Description

public Random\Randomizer::__serialize(): array

Warning

This function is currently not documented; only its argument list is available.

Parameters

This function has no parameters.

Return Values

Examples

Example #1 Random\Randomizer::__serialize() example

<?php

/* ... */

?>

The above example will output something similar to:

...
add a note

User Contributed Notes 1 note

up
0
vip3r011 dot sama at gmail dot com
1 month ago
$engine = new \Random\Engine\Xoshiro256StarStar();

$randomizer = new \Random\Randomizer($engine);

echo "First random number: " . $randomizer->getInt(1, 100) . PHP_EOL;

$serializedEngine = serialize($engine);

$restoredEngine = unserialize($serializedEngine);
$restoredRandomizer = new \Random\Randomizer($restoredEngine);

echo "Second random number (after restore): " . $restoredRandomizer->getInt(1, 100) . PHP_EOL;
To Top