3v4l.org

run code in 300+ PHP versions simultaneously
<?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]);
Output for 8.1.0 - 8.1.27, 8.2.0 - 8.2.17, 8.3.0 - 8.3.4
Deprecated: Entry 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/ZORdG on line 3 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 7.0.0 - 7.0.20, 7.1.0 - 7.1.33, 7.2.0 - 7.2.33, 7.3.0 - 7.3.33, 7.4.0 - 7.4.33, 8.0.0 - 8.0.30
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.4.45, 5.5.24 - 5.5.35, 5.6.8 - 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.

preferences:
192.88 ms | 402 KiB | 267 Q