3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php interface BarInterface { /** * Bazzes the current environment. */ public function baz(); } class Foo implements FooInterface { /** * @var \BarInterface */ protected $bar; /** * Constructs a new instance. * * @param \BarInterface $bar */ public function __construct(BarInterface $bar) { $this->bar = $bar; } /** * Bazzes the bar. */ public function baz() { $this->bar->baz(); } } class NullBar implements BarInterface { /** * {@inheritdoc} */ public function baz() { // Silently fail. } } class ShoutBar implements BarInterface { /** * {@inheritdoc} */ public function baz() { print "HELLO BAZ!"; } } $null_bar = new NullBar(); $shout_bar = new ShoutBar(); $null_bar_foo = new Foo($null_bar); $null_bar_foo->baz(); $shout_bar_foo = new Foo($shout_bar); $shout_bar_foo->baz();
Output for 5.0.5 - 7.1.0
Fatal error: Interface 'FooInterface' not found in /in/1ohuo on line 11
Process exited with code 255.
Output for 5.0.0 - 5.0.4
Fatal error: Class 'FooInterface' not found in /in/1ohuo on line 11
Process exited with code 255.
Output for 4.4.2 - 4.4.9
Parse error: syntax error, unexpected T_STRING in /in/1ohuo on line 2
Process exited with code 255.
Output for 4.3.0 - 4.3.1, 4.3.5 - 4.4.1
Parse error: parse error, unexpected T_STRING in /in/1ohuo on line 2
Process exited with code 255.
Output for 4.3.2 - 4.3.4
Parse error: parse error in /in/1ohuo on line 2
Process exited with code 255.