3v4l.org

run code in 300+ PHP versions simultaneously
<?php class test { private $f; public function __construct(&$f) { $this->f = &$f; } public function __destruct() { $this->f = function() {echo "... and be replaced with a new one!\n";}; } } $f = function () use (&$f) { $t = new test($f); print "After this line it the original Closure should be destroyed...\n"; }; $f(); $f(); var_dump($f);

preferences:
43.05 ms | 402 KiB | 5 Q