3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php class Entry implements \Serializable { protected $id; protected $role; public function __construct($id, $role) { $this->id = $id; $this->role = $role; } public function serialize() { return serialize([$this->id, $this->role]); } } class FieldEntry extends Entry implements \Serializable { protected $field; public function __construct($id, $role, $field) { parent::__construct($id, $role); $this->field = $field; } public function serialize() { return serialize([$this->field, parent::serialize()]); } } class Role { protected $name; public function __construct($name) { $this->name = $name; } } $b = new Role('test'); $a = new FieldEntry(1, $b, 'name'); $a1 = new FieldEntry(2, $b, 'age'); $s = serialize( array( // Acl:serialize (line 260) [ // classFieldAces 'fieldOne' => [$a], 'fieldTwo' => [$a1], ] ) ); var_dump($s); $uns = unserialize($s); var_dump($uns[0]['fieldOne'][0], $uns[0]['fieldTwo'][0]);
based on r4fC8
Output for 7.0.0 - 7.2.0
Fatal error: Class Entry contains 1 abstract method and must therefore be declared abstract or implement the remaining methods (Serializable::unserialize) in /in/ZORdG on line 3
Process exited with code 255.
Output for 5.4.2 - 5.6.28
Fatal error: Class Entry contains 1 abstract method and must therefore be declared abstract or implement the remaining methods (Serializable::unserialize) in /in/ZORdG on line 18
Process exited with code 255.
Output for 5.3.18 - 5.3.29
Parse error: syntax error, unexpected '[', expecting ')' in /in/ZORdG on line 16
Process exited with code 255.