3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Bar {} class Foo implements Serializable { public $test; public function __construct($test) { $this->test = $test; } public function serialize() { return $this->test; } public function unserialize($serialized) { //the following line causes problems unserialize('O:3:"Bar":1:{s:4:"bar1";O:3:"Bar":0:{}}'); $this->test = $serialized; } } $foo1 = new Foo('foo1'); $foo2 = new Foo('foo2'); $foo3 = new Foo('foo3'); $ar = array( array( 'instance' => $foo1, ), array( 'instance' => $foo2, ), array( 'instance' => $foo3, 'parent' => $foo2 ) ); $ar = serialize($ar); $ar = unserialize($ar); print_r($ar);

preferences:
45.45 ms | 402 KiB | 5 Q