3v4l.org

run code in 300+ PHP versions simultaneously
<?php interface A { public function foo(); } class B implements A { public function foo() { echo "foo"; } public function bar() { echo "bar"; } } class C { public function __construct(protected A $prop) { $this->prop->foo(); } } class D extends C { public function __construct(B $prop) {// Remove "protected" so that this is just an argument, not a property // Call the parent so that the field has a value parent::__construct($prop); $this->prop->bar(); } } $b = new B(); $d = new D($b);
Output for git.master, git.master_jit
foobar

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