3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Foo { protected $bar; public function __construct(BarInterface $bar) { $this->bar = $bar; } public function doAction() { $bar->getVar(); } } interface BarInterface { public function getVar() {} } abstract class BarAbscract implements BarInterface { public function getVar() { return $this->var; } } class Bar extends BarAbscract { protected $var = __CLASS__; } class Baz extends BarAbstract { protected $var = __CLASS__; } $bar = new Bar(); $foo = new Foo($bar); $foo->doAction();
Output for 5.5.24 - 5.5.30, 5.6.8 - 5.6.15
Fatal error: Interface function BarInterface::getVar() cannot contain body in /in/gZgoi on line 19
Process exited with code 255.

preferences:
161.27 ms | 1395 KiB | 22 Q