<?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); }
You have javascript disabled. You will not be able to edit any code.