3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php class B { public $value; function __construct($value){ $this->value = $value; } function __wakeup() { if($this->value instanceof C) $this->value = C::$instance; } } class C { static public $instance; } C::$instance = new C; $A = array( new B(C::$instance), new B(C::$instance), new B(C::$instance) ); var_dump($A); var_dump($A); $A = unserialize(serialize($A)); var_dump($A);
Output for 5.4.39 - 5.6.28, 7.0.0 - 7.1.0
array(3) { [0]=> object(B)#2 (1) { ["value"]=> object(C)#1 (0) { } } [1]=> object(B)#3 (1) { ["value"]=> object(C)#1 (0) { } } [2]=> object(B)#4 (1) { ["value"]=> object(C)#1 (0) { } } } array(3) { [0]=> object(B)#2 (1) { ["value"]=> object(C)#1 (0) { } } [1]=> object(B)#3 (1) { ["value"]=> object(C)#1 (0) { } } [2]=> object(B)#4 (1) { ["value"]=> object(C)#1 (0) { } } } array(3) { [0]=> object(B)#5 (1) { ["value"]=> object(C)#1 (0) { } } [1]=> object(B)#7 (1) { ["value"]=> object(C)#1 (0) { } } [2]=> object(B)#8 (1) { ["value"]=> object(C)#1 (0) { } } }
Output for hhvm-3.12.0
array(3) { [0]=> object(B)#2 (1) { ["value"]=> object(C)#1 (0) { } } [1]=> object(B)#3 (1) { ["value"]=> object(C)#1 (0) { } } [2]=> object(B)#4 (1) { ["value"]=> object(C)#1 (0) { } } } array(3) { [0]=> object(B)#2 (1) { ["value"]=> object(C)#1 (0) { } } [1]=> object(B)#3 (1) { ["value"]=> object(C)#1 (0) { } } [2]=> object(B)#4 (1) { ["value"]=> object(C)#1 (0) { } } } array(3) { [0]=> object(B)#5 (1) { ["value"]=> object(C)#1 (0) { } } [1]=> object(B)#6 (1) { ["value"]=> object(C)#1 (0) { } } [2]=> object(B)#7 (1) { ["value"]=> object(C)#1 (0) { } } }
Output for hhvm-3.10.0

Process exited with code 153.
Output for 5.2.14 - 5.2.17, 5.3.3 - 5.3.14, 5.4.0 - 5.4.38
array(3) { [0]=> object(B)#2 (1) { ["value"]=> object(C)#1 (0) { } } [1]=> object(B)#3 (1) { ["value"]=> object(C)#1 (0) { } } [2]=> object(B)#4 (1) { ["value"]=> object(C)#1 (0) { } } } array(3) { [0]=> object(B)#2 (1) { ["value"]=> object(C)#1 (0) { } } [1]=> object(B)#3 (1) { ["value"]=> object(C)#1 (0) { } } [2]=> object(B)#4 (1) { ["value"]=> object(C)#1 (0) { } } } array(3) { [0]=> object(B)#5 (1) { ["value"]=> object(C)#1 (0) { } } [1]=> object(B)#6 (1) { ["value"]=> *RECURSION* } [2]=> object(B)#7 (1) { ["value"]=> object(B)#6 (1) { ["value"]=> *RECURSION* } } }
Output for 5.3.15 - 5.3.29
array(3) { [0]=> object(B)#2 (1) { ["value"]=> object(C)#1 (0) { } } [1]=> object(B)#3 (1) { ["value"]=> object(C)#1 (0) { } } [2]=> object(B)#4 (1) { ["value"]=> object(C)#1 (0) { } } } array(3) { [0]=> object(B)#2 (1) { ["value"]=> object(C)#1 (0) { } } [1]=> object(B)#3 (1) { ["value"]=> object(C)#1 (0) { } } [2]=> object(B)#4 (1) { ["value"]=> object(C)#1 (0) { } } }
Process exited with code 139.
Output for 5.0.0 - 5.2.13, 5.3.0 - 5.3.2
array(3) { [0]=> object(B)#2 (1) { ["value"]=> object(C)#1 (0) { } } [1]=> object(B)#3 (1) { ["value"]=> object(C)#1 (0) { } } [2]=> object(B)#4 (1) { ["value"]=> object(C)#1 (0) { } } } array(3) { [0]=> object(B)#2 (1) { ["value"]=> object(C)#1 (0) { } } [1]=> object(B)#3 (1) { ["value"]=> object(C)#1 (0) { } } [2]=> object(B)#4 (1) { ["value"]=> object(C)#1 (0) { } } } array(3) { [0]=> object(B)#5 (1) { ["value"]=> object(C)#1 (0) { } } [1]=> object(B)#6 (1) { ["value"]=> object(B)#6 (1) { ["value"]=> *RECURSION* } } [2]=> object(B)#7 (1) { ["value"]=> object(B)#6 (1) { ["value"]=> object(B)#6 (1) { ["value"]=> *RECURSION* } } } }
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/RG5T5 on line 4
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/RG5T5 on line 4
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/RG5T5 on line 4
Process exited with code 255.