php8.5
Home/ Manual/ spl / splobjectstorage/ SplObjectStorage::unserialize

SplObjectStorage::unserialize

PHP function Edit on GitHub ✎

(PHP 5 >= 5.2.2, PHP 7, PHP 8)

Unserializes a storage from its string representation

Description

SplObjectStorage::unserialize(string $data): void

Unserializes storage entries and attach them to the current storage.

Parameters

data

The serialized representation of a storage.

Return Values

Void

Examples

SplObjectStorage::unserialize() example

php
<?php
$s1 = new SplObjectStorage;
$s2 = new SplObjectStorage;
$o = new stdClass;
$s1[$o] = "data";

$s2->unserialize($s1->serialize());

var_dump(count($s2));
?>

The above example will output something similar to:

output
int(1)

See Also

  • SplObjectStorage::serialize

Source: reference/spl/splobjectstorage/unserialize.xml · from the official PHP manual (php/doc-en)