3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?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 5.4.45, 5.5.29 - 5.5.38, 5.6.13 - 5.6.28, 7.0.14 - 7.1.0
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.3.0 - 5.3.29, hhvm-3.10.0 - 3.12.0
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.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.1.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.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.