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]); } public function unserialize($string) { list ($this->id, $this->role) = unserialize($string); } } 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()]); } public function unserialize($string) { list($this->field, $parentStr) = unserialize($string); parent::unserialize($parentStr); } } class Role { private $role; public function __construct($name) { $this->role = $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 git.master, git.master_jit
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/pM0E2 on line 3 Deprecated: FieldEntry 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/pM0E2 on line 25 string(261) "a:1:{i:0;a:2:{s:8:"fieldOne";a:1:{i:0;C:10:"FieldEntry":95:{a:2:{i:0;s:4:"name";i:1;s:62:"a:2:{i:0;i:1;i:1;O:4:"Role":1:{s:10:"Rolerole";s:4:"test";}}";}}}s:8:"fieldTwo";a:1:{i:0;C:10:"FieldEntry":54:{a:2:{i:0;s:3:"age";i:1;s:22:"a:2:{i:0;i:2;i:1;r:7;}";}}}}}" Notice: unserialize(): Error at offset 21 of 22 bytes in /in/pM0E2 on line 21 object(FieldEntry)#4 (3) { ["id":protected]=> int(1) ["role":protected]=> object(Role)#5 (1) { ["role":"Role":private]=> string(4) "test" } ["field":protected]=> string(4) "name" } object(FieldEntry)#6 (3) { ["id":protected]=> NULL ["role":protected]=> NULL ["field":protected]=> string(3) "age" }
Output for rfc.property-hooks
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/pM0E2 on line 3 Deprecated: FieldEntry 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/pM0E2 on line 25 string(261) "a:1:{i:0;a:2:{s:8:"fieldOne";a:1:{i:0;C:10:"FieldEntry":95:{a:2:{i:0;s:4:"name";i:1;s:62:"a:2:{i:0;i:1;i:1;O:4:"Role":1:{s:10:"Rolerole";s:4:"test";}}";}}}s:8:"fieldTwo";a:1:{i:0;C:10:"FieldEntry":54:{a:2:{i:0;s:3:"age";i:1;s:22:"a:2:{i:0;i:2;i:1;r:7;}";}}}}}" Warning: unserialize(): Error at offset 21 of 22 bytes in /in/pM0E2 on line 21 object(FieldEntry)#4 (3) { ["id":protected]=> int(1) ["role":protected]=> object(Role)#5 (1) { ["role":"Role":private]=> string(4) "test" } ["field":protected]=> string(4) "name" } object(FieldEntry)#6 (3) { ["id":protected]=> NULL ["role":protected]=> NULL ["field":protected]=> string(3) "age" }

This tab shows result from various feature-branches currently under review by the php developers. Contact me to have additional branches featured.

Active branches

Archived branches

Once feature-branches are merged or declined, they are no longer available. Their functionality (when merged) can be viewed from the main output page


preferences:
50.26 ms | 403 KiB | 8 Q