3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Foo { public $foo; public function __wakeup() { echo 'In foo', PHP_EOL, PHP_EOL; $this->foo = null; } public function __destruct() { echo 'Destruct foo', PHP_EOL, PHP_EOL; } } class Bar { public $bar; public function __wakeup() { echo 'In bar', PHP_EOL, PHP_EOL; $this->bar = null; } public function __destruct() { echo 'Destruct bar', PHP_EOL, PHP_EOL; throw new \Exception('x'); } } $f = new Foo; $b = new Bar; $f->foo = $b; $b->bar = $f; try { var_dump(unserialize(serialize([$f]))); } catch (\Throwable $e) { echo $e, PHP_EOL, PHP_EOL; } echo "==========", PHP_EOL, PHP_EOL; try { var_dump(unserialize(serialize([$f, $b]))); } catch (\Throwable $e) { echo $e, PHP_EOL, PHP_EOL; } echo "==========", PHP_EOL, PHP_EOL; try { var_dump(unserialize(serialize([$b, $f]))); } catch (\Throwable $e) { echo $e, PHP_EOL, PHP_EOL; } echo "==========", PHP_EOL, PHP_EOL;
Output for git.master, git.master_jit, rfc.property-hooks
In bar In foo Destruct bar Exception: x in /in/tnh2R:26 Stack trace: #0 /in/tnh2R(8): Bar->__destruct() #1 [internal function]: Foo->__wakeup() #2 /in/tnh2R(36): unserialize('a:1:{i:0;O:3:"F...') #3 {main} ========== In bar In foo array(2) { [0]=> object(Foo)#3 (1) { ["foo"]=> NULL } [1]=> object(Bar)#4 (1) { ["bar"]=> NULL } } Destruct foo Destruct bar Exception: x in /in/tnh2R:26 Stack trace: #0 /in/tnh2R(43): Bar->__destruct() #1 {main} ========== In foo In bar array(2) { [0]=> object(Bar)#5 (1) { ["bar"]=> NULL } [1]=> object(Foo)#4 (1) { ["foo"]=> NULL } } Destruct bar Destruct foo Exception: x in /in/tnh2R:26 Stack trace: #0 /in/tnh2R(49): Bar->__destruct() #1 {main} ========== Destruct foo Destruct bar Fatal error: Uncaught Exception: x in /in/tnh2R:26 Stack trace: #0 [internal function]: Bar->__destruct() #1 {main} thrown in /in/tnh2R on line 26
Process exited with code 255.

This tab shows result from various feature-branches currently under review by the php developers. Contact me to have additional branches featured.

Active branches

Archived branches

Once feature-branches are merged or declined, they are no longer available. Their functionality (when merged) can be viewed from the main output page


preferences:
51.61 ms | 402 KiB | 8 Q