3v4l.org

run code in 300+ PHP versions simultaneously
<?php $fn = function () { return get_called_class(); }; var_dump((new ReflectionFunction($fn))->getClosureScopeClass()); class C { private static $test = 'In 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 () { var_dump(D::$test); return get_called_class(); }; $res = (new ReflectionFunction($fn))->getClosureScopeClass(); var_dump(get_class($res)); var_dump($res->getName()); var_dump(static::$test); return $fn; } } class D extends C { private static $test = 'In class D'; public function __construct() { } public static function test() { return static::s_fn(); } } $d = new D; $func = D::test(); var_dump($func());
Output for git.master, git.master_jit, rfc.property-hooks
NULL string(15) "ReflectionClass" string(1) "C" Fatal error: Uncaught Error: Cannot access private property D::$test in /in/eT7bP:21 Stack trace: #0 /in/eT7bP(30): C::s_fn() #1 /in/eT7bP(35): D::test() #2 {main} thrown in /in/eT7bP on line 21
Process exited with code 255.

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