3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Permission implements \Serializable { protected $id = 3; public function serialize() { return serialize(array($this->id)); } public function unserialize($serialized) { list($this->id) = unserialize($serialized); } } class UserPermission implements \Serializable { public $permission; public $webshop; public function serialize() { return serialize(array($this->webshop, $this->permission)); } public function unserialize($serialized) { list($this->webshop, $this->permission) = unserialize($serialized); } } class Webshop implements \Serializable { protected $id = 0xAAAAAAAAAAAAAAAA; public function serialize() { return serialize(array($this->id)); } public function unserialize($serialized) { list($this->id) = unserialize($serialized); } } class AbstractToken implements \Serializable { public $roles; public function serialize() { return serialize(array($this->roles)); } public function unserialize($serialized) { list($this->roles) = unserialize($serialized); } } class UsernamePasswordToken extends AbstractToken { private $credentials = null; private $providerKey = null; public function serialize() { return serialize(array($this->credentials, $this->providerKey, parent::serialize())); } public function unserialize($str) { list($this->credentials, $this->providerKey, $parentStr) = unserialize($str); parent::unserialize($parentStr); } } $token = new UsernamePasswordToken(); $webshop = new Webshop; $permission = new Permission; $roles = array(); for ($i = 0; $i < 2; $i++) { $roles[$i] = new UserPermission(); $roles[$i]->webshop = $webshop; $roles[$i]->permission = $permission; } $token->roles = $roles; var_dump(unserialize(serialize($token)));
Output for 8.3.0 - 8.3.7
Deprecated: Permission 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/OL0gW on line 2 Deprecated: UserPermission 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/OL0gW on line 15 Deprecated: Webshop 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/OL0gW on line 29 Deprecated: AbstractToken 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/OL0gW on line 42 Deprecated: UsernamePasswordToken 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/OL0gW on line 55 Warning: unserialize(): Error at offset 13 of 22 bytes in /in/OL0gW on line 25 object(UsernamePasswordToken)#6 (3) { ["roles"]=> array(2) { [0]=> object(UserPermission)#7 (2) { ["permission"]=> object(Permission)#9 (1) { ["id":protected]=> int(3) } ["webshop"]=> object(Webshop)#8 (1) { ["id":protected]=> float(1.2297829382473034E+19) } } [1]=> object(UserPermission)#10 (2) { ["permission"]=> NULL ["webshop"]=> NULL } } ["credentials":"UsernamePasswordToken":private]=> NULL ["providerKey":"UsernamePasswordToken":private]=> NULL }
Output for 8.1.0 - 8.1.28, 8.2.0 - 8.2.19
Deprecated: Permission 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/OL0gW on line 2 Deprecated: UserPermission 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/OL0gW on line 15 Deprecated: Webshop 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/OL0gW on line 29 Deprecated: AbstractToken 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/OL0gW on line 42 Deprecated: UsernamePasswordToken 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/OL0gW on line 55 Notice: unserialize(): Error at offset 13 of 22 bytes in /in/OL0gW on line 25 object(UsernamePasswordToken)#6 (3) { ["roles"]=> array(2) { [0]=> object(UserPermission)#7 (2) { ["permission"]=> object(Permission)#9 (1) { ["id":protected]=> int(3) } ["webshop"]=> object(Webshop)#8 (1) { ["id":protected]=> float(1.2297829382473034E+19) } } [1]=> object(UserPermission)#10 (2) { ["permission"]=> NULL ["webshop"]=> NULL } } ["credentials":"UsernamePasswordToken":private]=> NULL ["providerKey":"UsernamePasswordToken":private]=> NULL }
Output for 8.0.0 - 8.0.30
Notice: unserialize(): Error at offset 13 of 22 bytes in /in/OL0gW on line 25 object(UsernamePasswordToken)#6 (3) { ["credentials":"UsernamePasswordToken":private]=> NULL ["providerKey":"UsernamePasswordToken":private]=> NULL ["roles"]=> array(2) { [0]=> object(UserPermission)#7 (2) { ["permission"]=> object(Permission)#9 (1) { ["id":protected]=> int(3) } ["webshop"]=> object(Webshop)#8 (1) { ["id":protected]=> float(1.2297829382473034E+19) } } [1]=> object(UserPermission)#10 (2) { ["permission"]=> NULL ["webshop"]=> NULL } } }
Output for 7.3.12 - 7.3.31, 7.4.0 - 7.4.33
Notice: unserialize(): Error at offset 13 of 22 bytes in /in/OL0gW on line 25 object(UsernamePasswordToken)#6 (3) { ["credentials":"UsernamePasswordToken":private]=> NULL ["providerKey":"UsernamePasswordToken":private]=> NULL ["roles"]=> array(2) { [0]=> object(UserPermission)#7 (2) { ["permission"]=> object(Permission)#9 (1) { ["id":protected]=> int(3) } ["webshop"]=> object(Webshop)#8 (1) { ["id":protected]=> float(1.2297829382473E+19) } } [1]=> object(UserPermission)#10 (2) { ["permission"]=> NULL ["webshop"]=> NULL } } }
Output for 7.3.32 - 7.3.33
object(UsernamePasswordToken)#6 (3) { ["credentials":"UsernamePasswordToken":private]=> NULL ["providerKey":"UsernamePasswordToken":private]=> NULL ["roles"]=> array(2) { [0]=> object(UserPermission)#7 (2) { ["permission"]=> object(Permission)#9 (1) { ["id":protected]=> int(3) } ["webshop"]=> object(Webshop)#8 (1) { ["id":protected]=> float(1.2297829382473E+19) } } [1]=> object(UserPermission)#10 (2) { ["permission"]=> NULL ["webshop"]=> NULL } } }
Output for 5.4.45, 5.5.29 - 5.5.38, 5.6.13 - 5.6.28, 7.0.14 - 7.0.20, 7.1.0 - 7.1.20, 7.2.0 - 7.2.33
object(UsernamePasswordToken)#6 (3) { ["credentials":"UsernamePasswordToken":private]=> NULL ["providerKey":"UsernamePasswordToken":private]=> NULL ["roles"]=> array(2) { [0]=> object(UserPermission)#7 (2) { ["permission"]=> object(Permission)#9 (1) { ["id":protected]=> int(3) } ["webshop"]=> object(Webshop)#8 (1) { ["id":protected]=> float(1.2297829382473E+19) } } [1]=> object(UserPermission)#10 (2) { ["permission"]=> array(2) { [0]=> object(Webshop)#8 (1) { ["id":protected]=> float(1.2297829382473E+19) } [1]=> object(Permission)#9 (1) { ["id":protected]=> int(3) } } ["webshop"]=> array(1) { [0]=> *RECURSION* } } } }
Output for 7.0.0 - 7.0.10
object(UsernamePasswordToken)#6 (3) { ["credentials":"UsernamePasswordToken":private]=> NULL ["providerKey":"UsernamePasswordToken":private]=> NULL ["roles"]=> array(2) { [0]=> object(UserPermission)#7 (2) { ["permission"]=> object(Permission)#9 (1) { ["id":protected]=> int(3) } ["webshop"]=> object(Webshop)#8 (1) { ["id":protected]=> float(1.2297829382473E+19) } } [1]=> object(UserPermission)#10 (2) { ["permission"]=> array(2) { [0]=> array(1) { [0]=> *RECURSION* } [1]=> *RECURSION* } ["webshop"]=> array(1) { [0]=> *RECURSION* } } } }
Output for 5.4.0 - 5.4.44, 5.5.0 - 5.5.28, 5.6.0 - 5.6.12

Process exited with code 139.
Output for 5.3.0 - 5.3.29
object(UsernamePasswordToken)#6 (3) { ["credentials":"UsernamePasswordToken":private]=> NULL ["providerKey":"UsernamePasswordToken":private]=> NULL ["roles"]=> array(2) { [0]=> object(UserPermission)#7 (2) { ["permission"]=> object(Permission)#9 (1) { ["id":protected]=> int(3) } ["webshop"]=> object(Webshop)#8 (1) { ["id":protected]=> float(1.2297829382473E+19) } } [1]=> object(UserPermission)#10 (2) { ["permission"]=> object(Permission)#12 (1) { ["id":protected]=> int(3) } ["webshop"]=> object(Webshop)#11 (1) { ["id":protected]=> float(1.2297829382473E+19) } } } }
Output for 5.1.0 - 5.1.6, 5.2.0 - 5.2.17
Warning: Unexpected character in input: '\' (ASCII=92) state=1 in /in/OL0gW on line 2 Warning: Unexpected character in input: '\' (ASCII=92) state=1 in /in/OL0gW on line 15 Warning: Unexpected character in input: '\' (ASCII=92) state=1 in /in/OL0gW on line 29 Warning: Unexpected character in input: '\' (ASCII=92) state=1 in /in/OL0gW on line 42 object(UsernamePasswordToken)#6 (3) { ["credentials:private"]=> NULL ["providerKey:private"]=> NULL ["roles"]=> array(2) { [0]=> object(UserPermission)#7 (2) { ["permission"]=> object(Permission)#9 (1) { ["id:protected"]=> int(3) } ["webshop"]=> object(Webshop)#8 (1) { ["id:protected"]=> float(1.2297829382473E+19) } } [1]=> object(UserPermission)#10 (2) { ["permission"]=> object(Permission)#12 (1) { ["id:protected"]=> int(3) } ["webshop"]=> object(Webshop)#11 (1) { ["id:protected"]=> float(1.2297829382473E+19) } } } }
Output for 5.0.5
Warning: Unexpected character in input: '\' (ASCII=92) state=1 in /in/OL0gW on line 2 Warning: Unexpected character in input: '\' (ASCII=92) state=1 in /in/OL0gW on line 15 Warning: Unexpected character in input: '\' (ASCII=92) state=1 in /in/OL0gW on line 29 Warning: Unexpected character in input: '\' (ASCII=92) state=1 in /in/OL0gW on line 42 Fatal error: Interface 'Serializable' not found in /in/OL0gW on line 2
Process exited with code 255.
Output for 5.0.0 - 5.0.4
Warning: Unexpected character in input: '\' (ASCII=92) state=1 in /in/OL0gW on line 2 Warning: Unexpected character in input: '\' (ASCII=92) state=1 in /in/OL0gW on line 15 Warning: Unexpected character in input: '\' (ASCII=92) state=1 in /in/OL0gW on line 29 Warning: Unexpected character in input: '\' (ASCII=92) state=1 in /in/OL0gW on line 42 Fatal error: Class 'Serializable' not found in /in/OL0gW on line 2
Process exited with code 255.
Output for 4.4.2 - 4.4.9
Parse error: syntax error, unexpected T_STRING, expecting '{' in /in/OL0gW on line 2
Process exited with code 255.
Output for 4.3.0 - 4.3.1, 4.3.5 - 4.3.11, 4.4.0 - 4.4.1
Parse error: parse error, unexpected T_STRING, expecting '{' in /in/OL0gW on line 2
Process exited with code 255.
Output for 4.3.2 - 4.3.4
Parse error: parse error, expecting `'{'' in /in/OL0gW on line 2
Process exited with code 255.

preferences:
252.67 ms | 401 KiB | 358 Q