PHP 8.4.1 Released!

Random\Randomizer::__serialize

(PHP 8 >= 8.2.0)

Random\Randomizer::__serializeSerializes the Randomizer object

说明

public Random\Randomizer::__serialize(): array

警告

本函数还未编写文档,仅有参数列表。

参数

此函数没有参数。

返回值

示例

示例 #1 Random\Randomizer::__serialize() example

<?php

/* ... */

?>

以上示例的输出类似于:

...
添加备注

用户贡献的备注 1 note

up
0
vip3r011 dot sama at gmail dot com
2 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