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

SplObjectStorage::serialize

PHP function Edit on GitHub ✎

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

Serializes the storage

Description

SplObjectStorage::serialize(): string

Returns a string representation of the storage.

Parameters Parameters

Return Values

A string representing the storage.

Examples

SplObjectStorage::serialize() example

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

echo $s->serialize()."\n";
?>

The above example will output something similar to:

output
x:i:1;O:8:"stdClass":0:{},s:4:"data";;m:a:0:{}

See Also

  • SplObjectStorage::unserialize

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