3v4l.org

run code in 300+ PHP versions simultaneously
<?php class A { public static $data = ['a']; public static function getData() { $classes = class_parents($class); $classes[] = get_called_class(); return call_user_func_array('array_merge', array_map( function($class) { return $class::$data; }, $classes ) ); } } class B extends A { public static $data = ['b']; } class C extends B { public static $data = ['c']; } class D extends C { public static $data = ['d']; } var_dump(A::getData()); var_dump(B::getData()); var_dump(C::getData()); var_dump(D::getData());
Output for git.master, git.master_jit, rfc.property-hooks
Warning: Undefined variable $class in /in/9gfps on line 9 Fatal error: Uncaught TypeError: class_parents(): Argument #1 ($object_or_class) must be of type object|string, null given in /in/9gfps:9 Stack trace: #0 /in/9gfps(9): class_parents(NULL) #1 /in/9gfps(37): A::getData() #2 {main} thrown in /in/9gfps on line 9
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:
19.41 ms | 401 KiB | 8 Q