3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Foo { public int $v; public function makeClosure(int $v) { return function () use ($v) { echo $this->v . '-' . $v . "\n"; throw new \Exception(); }; } } $foo = new Foo(); $foo->v = 2; $fx = $foo->makeClosure(3); try { $fx(); } catch (\Throwable $e) { print_r($e); }
Output for git.master, git.master_jit
2-3 Exception Object ( [message:protected] => [string:Exception:private] => [code:protected] => 0 [file:protected] => /in/YqFcG [line:protected] => 10 [trace:Exception:private] => Array ( [0] => Array ( [file] => /in/YqFcG [line] => 20 [function] => {closure:Foo::makeClosure():8} [class] => Foo [type] => -> [args] => Array ( ) ) ) [previous:Exception:private] => )

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:
26.32 ms | 407 KiB | 5 Q