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); }

preferences:
25.22 ms | 404 KiB | 5 Q