3v4l.org

run code in 200+ 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 = 13; 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.0 - 5.4.16

Process exited with code 139.
Output for 5.3.0 - 5.3.26
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]=> int(13) } } [1]=> object(UserPermission)#10 (2) { ["permission"]=> object(Permission)#12 (1) { ["id":protected]=> int(3) } ["webshop"]=> object(Webshop)#11 (1) { ["id":protected]=> int(13) } } } }
Output for 5.1.0 - 5.2.17
Warning: Unexpected character in input: '\' (ASCII=92) state=1 in /in/QFDDc on line 2 Warning: Unexpected character in input: '\' (ASCII=92) state=1 in /in/QFDDc on line 15 Warning: Unexpected character in input: '\' (ASCII=92) state=1 in /in/QFDDc on line 29 Warning: Unexpected character in input: '\' (ASCII=92) state=1 in /in/QFDDc 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"]=> int(13) } } [1]=> object(UserPermission)#10 (2) { ["permission"]=> object(Permission)#12 (1) { ["id:protected"]=> int(3) } ["webshop"]=> object(Webshop)#11 (1) { ["id:protected"]=> int(13) } } } }
Output for 5.0.5
Warning: Unexpected character in input: '\' (ASCII=92) state=1 in /in/QFDDc on line 2 Warning: Unexpected character in input: '\' (ASCII=92) state=1 in /in/QFDDc on line 15 Warning: Unexpected character in input: '\' (ASCII=92) state=1 in /in/QFDDc on line 29 Warning: Unexpected character in input: '\' (ASCII=92) state=1 in /in/QFDDc on line 42 Fatal error: Interface 'Serializable' not found in /in/QFDDc 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/QFDDc on line 2 Warning: Unexpected character in input: '\' (ASCII=92) state=1 in /in/QFDDc on line 15 Warning: Unexpected character in input: '\' (ASCII=92) state=1 in /in/QFDDc on line 29 Warning: Unexpected character in input: '\' (ASCII=92) state=1 in /in/QFDDc on line 42 Fatal error: Class 'Serializable' not found in /in/QFDDc 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/QFDDc 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/QFDDc on line 2
Process exited with code 255.
Output for 4.3.2 - 4.3.4
Parse error: parse error, expecting `'{'' in /in/QFDDc on line 2
Process exited with code 255.