3v4l.org

run code in 300+ PHP versions simultaneously
<?php abstract class Component { protected $data; abstract public function getHtml(); } class ConcreteComponent extends Component { // public function __construct() // { // $this->data = "<body></body>"; // } public function getHtml() { // return $this->data; return "<body></body>"; } } abstract class Decorator extends Component { } class ConcreteDecorator1 extends Decorator { public function __construct(Component $data) { $this->data = $data; } public function getHtml() { return $this->data->getData() . "<p> </p>"; } } class ConcreteDecorator2 extends Decorator { public function __construct(Component $data) { $this->value = 500; $this->data = $data; } public function getHtml() { return "<span>".$this->data->getData()."</span>"; } } $compo = new ConcreteDecorator2(new ConcreteDecorator1(new ConcreteComponent())); echo $compo->getHtml(); // echo "Client:\t\t\t"; // echo $compo->getValue();
Output for git.master, git.master_jit, rfc.property-hooks
Deprecated: Creation of dynamic property ConcreteDecorator2::$value is deprecated in /in/a6Blm on line 46 Fatal error: Uncaught Error: Call to undefined method ConcreteDecorator1::getData() in /in/a6Blm:52 Stack trace: #0 /in/a6Blm(58): ConcreteDecorator2->getHtml() #1 {main} thrown in /in/a6Blm on line 52
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:
18.49 ms | 401 KiB | 8 Q