3v4l.org

run code in 300+ PHP versions simultaneously
<?php class foo { public function getFunc() { return function () { return true; }; } public function __destruct() { echo "Destructor\n"; } } $foo = new Foo(); $fn = $foo->getFunc(); unset($foo); echo "After Unset\n";
Output for 7.3.0 - 7.3.30, 7.4.0 - 7.4.23, 8.0.0 - 8.0.10, 8.1rc1
After Unset Destructor

preferences:
41.28 ms | 459 KiB | 5 Q