3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php class Tr { public $s; /** * Tr constructor. * @param $s */ public function __construct($s) { $this->s = $s; } public function __destruct() { echo "__destruct $this->s" . PHP_EOL; } } function b() { $tr = new Tr('b'); echo 'b' . PHP_EOL; c($tr); // If exception thrown here, Tr::__destruct is called throw new \Exception('ee'); // Or if you call c() without passing $tr, Tr::__destruct is called } /** * @param Tr $tr */ function c($tr = null) { //throw new \Exception('ee'); } b();
based on 2kbXq
Output for 7.0.0 - 7.3.0beta1
b __destruct b Fatal error: Uncaught Exception: ee in /in/js4iU:27 Stack trace: #0 /in/js4iU(39): b() #1 {main} thrown in /in/js4iU on line 27
Process exited with code 255.
Output for hhvm-3.22.0
b __destruct b Fatal error: Uncaught exception 'Exception' with message 'ee' in /in/js4iU:-1 Stack trace: #0 /in/js4iU(-1): b() #1 {main}
Process exited with code 255.
Output for hhvm-3.18.5 - 3.21.3
b __destruct b Fatal error: Uncaught exception 'Exception' with message 'ee' in /in/js4iU:27 Stack trace: #0 /in/js4iU(39): b() #1 {main}
Process exited with code 255.
Output for 5.6.0 - 5.6.30
b __destruct b Fatal error: Uncaught exception 'Exception' with message 'ee' in /in/js4iU:27 Stack trace: #0 /in/js4iU(39): b() #1 {main} thrown in /in/js4iU on line 27
Process exited with code 255.