3v4l.org

run code in 300+ PHP versions simultaneously
<?php interface Table { public function getTableName(); } class TableA implements Table { public function getTableName() { return 'TableA'; } } class TableB implements Table { public function getTableName() { return 'TableB'; } } class TableC implements Table { public function getTableName() { return 'TableC'; } } class TableD implements Table { public function getTableName() { return 'TableD'; } } class Service { public $tableA; public $tableB; public $tableC; public $tableD; public function __construct(Table $a, Table $b, Table $c, Table $d) { $this->tableA = $a; $this->tableB = $b; $this->tableC = $c; $this->tableD = $d; } public function table_A_and_B_doSomething() { echo $this->tableA->getTableName(), ' ', $this->tableB->getTableName(); } public function table_C_and_D_doSomething() { echo $this->tableC->getTableName(), ' ', $this->tableD->getTableName(); } } // Request A $service = new Service(new tableA(), new tableB(), new tableC(), new tableD()); $service->table_C_and_D_doSomething(); // Request B $service = new Service(new tableA(), new tableB(), new tableC(), new tableD()); $service->table_A_and_B_doSomething();
Output for git.master, git.master_jit, rfc.property-hooks
TableC TableDTableA TableB

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:
42.36 ms | 401 KiB | 8 Q