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
8 months 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

Follow Lee on X/Twitter - Father, Husband, Serial builder creating AI, crypto, games & web tools. We are friends :) AI Will Come To Life!

Check out: eBank.nz (Art Generator) | Netwrck.com (AI Tools) | Text-Generator.io (AI API) | BitBank.nz (Crypto AI) | ReadingTime (Kids Reading) | RewordGame | BigMultiplayerChess | WebFiddle | How.nz | Helix AI Assistant