3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php class ObjectWithReferences { protected $var1; protected $var2; public function __construct() { $this->var1 = new StdClass(); $this->var2 = $this->var1; } } class WrapperObject implements Serializable { private $obj; public function __construct($obj) { $this->obj = $obj; } public function getObject() { return $this->obj; } public function serialize() { for ($i = 0; $i < 15; ++$i) { var_dump(serialize(new \stdClass())); } return serialize($this->obj); } public function unserialize($serialized) { $this->obj = unserialize($serialized); } } $wrapper = new WrapperObject(new ObjectWithReferences()); var_dump($wrapper->getObject()); $serialized = serialize($wrapper); var_dump($serialized); $wrapper = unserialize($serialized);
Output for 7.0.0 - 7.1.0
object(ObjectWithReferences)#2 (2) { ["var1":protected]=> object(stdClass)#3 (0) { } ["var2":protected]=> object(stdClass)#3 (0) { } } string(19) "O:8:"stdClass":0:{}" string(19) "O:8:"stdClass":0:{}" string(19) "O:8:"stdClass":0:{}" string(19) "O:8:"stdClass":0:{}" string(19) "O:8:"stdClass":0:{}" string(19) "O:8:"stdClass":0:{}" string(19) "O:8:"stdClass":0:{}" string(19) "O:8:"stdClass":0:{}" string(19) "O:8:"stdClass":0:{}" string(19) "O:8:"stdClass":0:{}" string(19) "O:8:"stdClass":0:{}" string(19) "O:8:"stdClass":0:{}" string(19) "O:8:"stdClass":0:{}" string(19) "O:8:"stdClass":0:{}" string(19) "O:8:"stdClass":0:{}" string(110) "C:13:"WrapperObject":84:{O:20:"ObjectWithReferences":2:{s:7:"*var1";O:8:"stdClass":0:{}s:7:"*var2";r:18;}}" Notice: unserialize(): Error at offset 83 of 84 bytes in /in/XaTAq on line 34
Output for 5.4.22 - 5.6.28
object(ObjectWithReferences)#2 (2) { ["var1":protected]=> object(stdClass)#3 (0) { } ["var2":protected]=> object(stdClass)#3 (0) { } } string(19) "O:8:"stdClass":0:{}" string(19) "O:8:"stdClass":0:{}" string(19) "O:8:"stdClass":0:{}" string(4) "r:2;" string(4) "r:3;" string(4) "r:4;" string(4) "r:2;" string(4) "r:3;" string(4) "r:4;" string(4) "r:2;" string(4) "r:3;" string(4) "r:4;" string(4) "r:2;" string(4) "r:3;" string(4) "r:4;" string(110) "C:13:"WrapperObject":84:{O:20:"ObjectWithReferences":2:{s:7:"*var1";O:8:"stdClass":0:{}s:7:"*var2";r:18;}}" Notice: unserialize(): Error at offset 83 of 84 bytes in /in/XaTAq on line 34
Output for 5.4.0 - 5.4.21
object(ObjectWithReferences)#2 (2) { ["var1":protected]=> object(stdClass)#3 (0) { } ["var2":protected]=> object(stdClass)#3 (0) { } } string(19) "O:8:"stdClass":0:{}" string(4) "r:2;" string(4) "r:2;" string(4) "r:2;" string(4) "r:2;" string(4) "r:2;" string(4) "r:2;" string(4) "r:2;" string(4) "r:2;" string(4) "r:2;" string(4) "r:2;" string(4) "r:2;" string(4) "r:2;" string(4) "r:2;" string(4) "r:2;" string(110) "C:13:"WrapperObject":84:{O:20:"ObjectWithReferences":2:{s:7:"*var1";O:8:"stdClass":0:{}s:7:"*var2";r:18;}}" Notice: unserialize(): Error at offset 83 of 84 bytes in /in/XaTAq on line 34
Output for 5.3.0 - 5.3.29
object(ObjectWithReferences)#2 (2) { ["var1":protected]=> object(stdClass)#3 (0) { } ["var2":protected]=> object(stdClass)#3 (0) { } } string(19) "O:8:"stdClass":0:{}" string(19) "O:8:"stdClass":0:{}" string(19) "O:8:"stdClass":0:{}" string(19) "O:8:"stdClass":0:{}" string(19) "O:8:"stdClass":0:{}" string(19) "O:8:"stdClass":0:{}" string(19) "O:8:"stdClass":0:{}" string(19) "O:8:"stdClass":0:{}" string(19) "O:8:"stdClass":0:{}" string(19) "O:8:"stdClass":0:{}" string(19) "O:8:"stdClass":0:{}" string(19) "O:8:"stdClass":0:{}" string(19) "O:8:"stdClass":0:{}" string(19) "O:8:"stdClass":0:{}" string(19) "O:8:"stdClass":0:{}" string(109) "C:13:"WrapperObject":83:{O:20:"ObjectWithReferences":2:{s:7:"*var1";O:8:"stdClass":0:{}s:7:"*var2";r:2;}}"
Output for 5.1.0 - 5.2.17
Warning: Unexpected character in input: '\' (ASCII=92) state=1 in /in/XaTAq on line 27 object(ObjectWithReferences)#2 (2) { ["var1:protected"]=> object(stdClass)#3 (0) { } ["var2:protected"]=> object(stdClass)#3 (0) { } } string(19) "O:8:"stdClass":0:{}" string(19) "O:8:"stdClass":0:{}" string(19) "O:8:"stdClass":0:{}" string(19) "O:8:"stdClass":0:{}" string(19) "O:8:"stdClass":0:{}" string(19) "O:8:"stdClass":0:{}" string(19) "O:8:"stdClass":0:{}" string(19) "O:8:"stdClass":0:{}" string(19) "O:8:"stdClass":0:{}" string(19) "O:8:"stdClass":0:{}" string(19) "O:8:"stdClass":0:{}" string(19) "O:8:"stdClass":0:{}" string(19) "O:8:"stdClass":0:{}" string(19) "O:8:"stdClass":0:{}" string(19) "O:8:"stdClass":0:{}" string(109) "C:13:"WrapperObject":83:{O:20:"ObjectWithReferences":2:{s:7:"*var1";O:8:"stdClass":0:{}s:7:"*var2";r:2;}}"
Output for 5.0.5
Warning: Unexpected character in input: '\' (ASCII=92) state=1 in /in/XaTAq on line 27 Fatal error: Interface 'Serializable' not found in /in/XaTAq on line 13
Process exited with code 255.
Output for 5.0.0 - 5.0.4
Warning: Unexpected character in input: '\' (ASCII=92) state=1 in /in/XaTAq on line 27 Fatal error: Class 'Serializable' not found in /in/XaTAq on line 13
Process exited with code 255.
Output for 4.4.2 - 4.4.9
Parse error: syntax error, unexpected T_STRING, expecting T_OLD_FUNCTION or T_FUNCTION or T_VAR or '}' in /in/XaTAq on line 3
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 T_OLD_FUNCTION or T_FUNCTION or T_VAR or '}' in /in/XaTAq on line 3
Process exited with code 255.
Output for 4.3.2 - 4.3.4
Parse error: parse error, expecting `T_OLD_FUNCTION' or `T_FUNCTION' or `T_VAR' or `'}'' in /in/XaTAq on line 3
Process exited with code 255.