3v4l.org

run code in 300+ PHP versions simultaneously
<?php $fn = function () { return get_called_class(); }; var_dump((new ReflectionFunction($fn))->getClosureScopeClass()); class C { public function __construct() { $fn = function () { return get_called_class(); }; $res = (new ReflectionFunction($fn))->getClosureScopeClass(); var_dump(get_class($res)); var_dump($res->getName()); } public static function s_fn() { $fn = function () { return get_called_class(); }; $res = (new ReflectionFunction($fn))->getClosureScopeClass(); var_dump(get_class($res)); var_dump($res->getName()); } } class D extends C { public function __construct() { static::s_fn(); } } $c = new C; C::s_fn(); $d = new D;
Output for git.master, git.master_jit, rfc.property-hooks
NULL string(15) "ReflectionClass" string(1) "C" string(15) "ReflectionClass" string(1) "C" string(15) "ReflectionClass" string(1) "C"

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:
42.85 ms | 401 KiB | 8 Q