3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php class test { private $f; public function __construct(&$f) { $this->f = &$f; } public function __destruct() { $this->f = 1; // without this line: Catchable fatal error: Object of class Closure could not be converted to string $this->f = "Some random string"; } } $f = function () use (&$f) { $t = new test($f); print "after this parent $f shouldn't be a closure anymore...\n"; }; $f(); var_dump($f);
Output for 7.1.0 - 7.2.12
Recoverable fatal error: Object of class Closure could not be converted to string in /in/tAMPi on line 18
Process exited with code 255.
Output for 5.3.0 - 5.6.38, 7.0.0 - 7.0.32
Catchable fatal error: Object of class Closure could not be converted to string in /in/tAMPi on line 18
Process exited with code 255.
Output for hhvm-3.22.0
Fatal error: Uncaught Error: Object of class Closure$;4 could not be converted to string in /in/tAMPi:-1 Stack trace: #0 /in/tAMPi(-1): Closure$() #1 {main}
Process exited with code 255.
Output for hhvm-3.21.0 - 3.21.3
Fatal error: Uncaught Error: Object of class Closure$;4 could not be converted to string in /in/tAMPi:18 Stack trace: #0 /in/tAMPi(21): Closure$() #1 {main}
Process exited with code 255.
Output for hhvm-3.17.3 - 3.20.2
Fatal error: Uncaught Error: Object of class Closure$;2 could not be converted to string in /in/tAMPi:18 Stack trace: #0 /in/tAMPi(21): Closure$() #1 {main}
Process exited with code 255.
Output for hhvm-3.15.4
Fatal error: Uncaught Error: Object of class Closure$__destruct;386578012$a6347d14086145d41ae5bb855b5a1ea0$ could not be converted to string in /in/tAMPi:18 Stack trace: #0 /in/tAMPi(21): Closure$__destruct() #1 {main}
Process exited with code 255.
Output for hhvm-3.12.14 - 3.13.2
Fatal error: Uncaught Error: Object of class Closure$__destruct;386578012$6293b589429ad79eb01badc28dab41b3$ could not be converted to string in /in/tAMPi:18 Stack trace: #0 /in/tAMPi(21): Closure$__destruct() #1 {main}
Process exited with code 255.
Output for hhvm-3.11.1
Fatal error: Uncaught Error: Object of class Closure$__destruct;386578012$267fafb14fa4c5302b183755f9187c40$ could not be converted to string in /in/tAMPi:18 Stack trace: #0 /in/tAMPi(21): Closure$__destruct() #1 {main}
Process exited with code 255.
Output for hhvm-3.10.1
Catchable fatal error: Object of class Closure$__destruct;386578012$c028931f2a39e5eb18a6f09a8f1e3bfc$ could not be converted to string in /in/tAMPi on line 18
Process exited with code 255.
Output for 5.1.0 - 5.2.17
Parse error: syntax error, unexpected T_FUNCTION in /in/tAMPi on line 16
Process exited with code 255.
Output for 5.0.0 - 5.0.5
Parse error: parse error, unexpected T_FUNCTION in /in/tAMPi on line 16
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/tAMPi 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/tAMPi 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/tAMPi on line 4
Process exited with code 255.