3v4l.org

run code in 300+ PHP versions simultaneously
<?php trait dumper { public function doIt() { print "get_object_vars()\n"; print_r(get_object_vars($this)); $closure = \Closure::bind(static function ($class) { return get_object_vars($class); }, NULL, $this); $vars = $closure($this); print "\n\nClosure\n"; print_r($vars); } } class A { use dumper; private int $a = 1; } class B extends A { } class C extends B { use dumper; private int $a = 2; } print "Class A\n"; (new A())->doit(); print "\n\nClass B\n"; (new B())->doit(); print "\n\nClass C\n"; (new C())->doit();
Output for git.master_jit, git.master, rfc.property-hooks
Class A get_object_vars() Array ( [a] => 1 ) Closure Array ( [a] => 1 ) Class B get_object_vars() Array ( [a] => 1 ) Closure Array ( ) Class C get_object_vars() Array ( [a] => 2 ) Closure Array ( [a] => 2 )

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:
28.36 ms | 405 KiB | 5 Q