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(); } } $service = new Service(new tableA(), new tableB(), new tableC(), new tableD()); $service->table_C_and_D_doSomething();
Output for 5.4.0 - 5.4.34
Parse error: syntax error, unexpected 'a' (T_STRING), expecting '&' or variable (T_VARIABLE) in /in/6sDXT on line 38
Process exited with code 255.
Output for 5.1.0 - 5.1.6, 5.2.0 - 5.2.17, 5.3.0 - 5.3.29
Parse error: syntax error, unexpected T_STRING, expecting '&' or T_VARIABLE in /in/6sDXT on line 38
Process exited with code 255.
Output for 5.0.0 - 5.0.5
Parse error: parse error, unexpected T_STRING, expecting '&' or T_VARIABLE in /in/6sDXT on line 38
Process exited with code 255.
Output for 4.4.2 - 4.4.9
Parse error: syntax error, unexpected T_STRING in /in/6sDXT on line 2
Process exited with code 255.
Output for 4.3.0 - 4.3.1, 4.3.5 - 4.3.11, 4.4.0 - 4.4.1
Parse error: parse error, unexpected T_STRING in /in/6sDXT on line 2
Process exited with code 255.
Output for 4.3.2 - 4.3.4
Parse error: parse error in /in/6sDXT on line 2
Process exited with code 255.

preferences:
207.45 ms | 1395 KiB | 124 Q