3v4l.org

run code in 300+ PHP versions simultaneously
<?php class d implements \Serializable { /** @var */ private $v; public function __construct($v) { $this->v = $v; } /** * {@inheritdoc} */ public function serialize() { return serialize([$this->v]); } /** * {@inheritdoc} */ public function unserialize($serialized) { list($this->v) = unserialize($serialized); } } class a extends d { /** @var b */ private $b; public function __construct($v, b $b) { $this->b = $b; parent::__construct($v); } /** * {@inheritdoc} */ public function serialize() { return serialize([$this->b, parent::serialize()]); } /** * {@inheritdoc} */ public function unserialize($serialized) { list($this->b, $parentStr) = unserialize($serialized); parent::unserialize($parentStr); } /** * @return b */ public function getB() { return $this->b; } } class b { private $b; public function __construct($b) { $this->b = $b; } } $b = new b('test'); $t = [ // Acl:serialize (line 260) [ // classFieldAces 'fieldOne' => [new a(1, $b)], 'fieldTwo' => [new a(2, $b)], ] ]; $t = serialize($t); $t = serialize([1, $t]); list($sss, $uns) = unserialize($t); $uns = unserialize($uns); var_dump($uns); var_dump($uns[0]['fieldOne'][0]->getB() === $uns[0]['fieldTwo'][0]->getB());
Output for 8.3.0 - 8.3.7
Deprecated: d 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/viORV on line 3 Deprecated: a 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/viORV on line 30 Warning: unserialize(): Error at offset 13 of 40 bytes in /in/viORV on line 53 Deprecated: unserialize(): Passing null to parameter #1 ($data) of type string is deprecated in /in/viORV on line 27 array(1) { [0]=> array(2) { ["fieldOne"]=> array(1) { [0]=> object(a)#3 (2) { ["v":"d":private]=> int(1) ["b":"a":private]=> object(b)#2 (1) { ["b":"b":private]=> string(4) "test" } } } ["fieldTwo"]=> array(1) { [0]=> object(a)#4 (2) { ["v":"d":private]=> NULL ["b":"a":private]=> NULL } } } } bool(false)
Output for 8.1.0 - 8.1.28, 8.2.0 - 8.2.19
Deprecated: d 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/viORV on line 3 Deprecated: a 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/viORV on line 30 Notice: unserialize(): Error at offset 13 of 40 bytes in /in/viORV on line 53 Deprecated: unserialize(): Passing null to parameter #1 ($data) of type string is deprecated in /in/viORV on line 27 array(1) { [0]=> array(2) { ["fieldOne"]=> array(1) { [0]=> object(a)#3 (2) { ["v":"d":private]=> int(1) ["b":"a":private]=> object(b)#2 (1) { ["b":"b":private]=> string(4) "test" } } } ["fieldTwo"]=> array(1) { [0]=> object(a)#4 (2) { ["v":"d":private]=> NULL ["b":"a":private]=> NULL } } } } bool(false)
Output for 7.3.0 - 7.3.31, 7.4.0 - 7.4.33, 8.0.0 - 8.0.30
Notice: unserialize(): Error at offset 13 of 40 bytes in /in/viORV on line 53 array(1) { [0]=> array(2) { ["fieldOne"]=> array(1) { [0]=> object(a)#3 (2) { ["b":"a":private]=> object(b)#2 (1) { ["b":"b":private]=> string(4) "test" } ["v":"d":private]=> int(1) } } ["fieldTwo"]=> array(1) { [0]=> object(a)#4 (2) { ["b":"a":private]=> NULL ["v":"d":private]=> NULL } } } } bool(false)
Output for 7.3.32 - 7.3.33
array(1) { [0]=> array(2) { ["fieldOne"]=> array(1) { [0]=> object(a)#3 (2) { ["b":"a":private]=> object(b)#2 (1) { ["b":"b":private]=> string(4) "test" } ["v":"d":private]=> int(1) } } ["fieldTwo"]=> array(1) { [0]=> object(a)#4 (2) { ["b":"a":private]=> NULL ["v":"d":private]=> NULL } } } } bool(false)
Output for 5.4.39 - 5.4.45, 5.5.24 - 5.5.35, 5.6.8 - 5.6.28, 7.0.0 - 7.0.20, 7.1.0 - 7.1.33, 7.2.6 - 7.2.33
array(1) { [0]=> array(2) { ["fieldOne"]=> array(1) { [0]=> object(a)#3 (2) { ["b":"a":private]=> object(b)#2 (1) { ["b":"b":private]=> string(4) "test" } ["v":"d":private]=> int(1) } } ["fieldTwo"]=> array(1) { [0]=> object(a)#4 (2) { ["b":"a":private]=> string(14) "a:1:{i:0;i:1;}" ["v":"d":private]=> int(2) } } } } bool(false)
Output for 5.4.2 - 5.4.38

Process exited with code 139.

preferences:
147.36 ms | 401 KiB | 257 Q