<?php
class Example implements Serializable
{
/* Serializable */
public function serialize()
{
// We need to serialize everything because a run-time object of this class hasn't a reference
return serialize(array(
'label' => 'a label',
'links' => 'some links',
'attrs' => 'some attrs',
));
}
public function unserialize($s)
{
return 'pie';
}
}
$o = new Example;
$o->self = $o;
echo serialize($o);
Deprecated: Example implements the Serializable interface, which is deprecated. Implement __serialize() and __unserialize() instead (or in addition, if support for old PHP versions is necessary) in /in/PV0m7 on line 3
Deprecated: Creation of dynamic property Example::$self is deprecated in /in/PV0m7 on line 22
C:7:"Example":92:{a:3:{s:5:"label";s:7:"a label";s:5:"links";s:10:"some links";s:5:"attrs";s:10:"some attrs";}}
Output for 8.1.0 - 8.1.27
Deprecated: Example implements the Serializable interface, which is deprecated. Implement __serialize() and __unserialize() instead (or in addition, if support for old PHP versions is necessary) in /in/PV0m7 on line 3
C:7:"Example":92:{a:3:{s:5:"label";s:7:"a label";s:5:"links";s:10:"some links";s:5:"attrs";s:10:"some attrs";}}