3v4l.org

run code in 300+ PHP versions simultaneously
<?php class A { static $data = ['a']; static function getData() { return self::$data; } } class B extends A { static $data = ['b']; static function getData() { return array_merge(parent::getData(), self::$data); } } class C extends B { static $data = ['c']; static function getData() { return array_merge(parent::getData(), self::$data); } } class D extends B { static $data = ['d']; static function getData() { return array_merge(parent::getData(), self::$data); } } $a = new A; $b = new B; $c = new C; $d = new D; var_dump($a::getData()); // Array('a'); var_dump($b::getData()); // Array('a', 'b'); var_dump($c::getData()); // Array('a', 'b', 'c'); var_dump($d::getData()); // Array('a', 'b', 'd');
Output for git.master, git.master_jit, rfc.property-hooks
array(1) { [0]=> string(1) "a" } array(2) { [0]=> string(1) "a" [1]=> string(1) "b" } array(3) { [0]=> string(1) "a" [1]=> string(1) "b" [2]=> string(1) "c" } array(3) { [0]=> string(1) "a" [1]=> string(1) "b" [2]=> string(1) "d" }

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:
41 ms | 406 KiB | 5 Q