3v4l.org

run code in 300+ PHP versions simultaneously
<?php trait X { public function test() {echo 'this is from A';} } class A { use X; } class B extends A { public function test() {echo 'this is from B';} } class C extends B { public function run() { $this->test(); // this outputs 'this is from A' !!! } // however if I include this function, it works correctly by echoing 'this is from B' // public function test() { // parent::test(); // } // whats even more weird, is that an almost identical class D works correctly } (new C())->run();
Output for git.master, git.master_jit, rfc.property-hooks
this is from B

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