3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php interface Logger { public function log(string $msg); } class Application { private $logger; public function getLogger(): Logger { return $this->logger; } public function setLogger(Logger $logger) { $this->logger = $logger; } } $app = new Application; $app->setLogger(new class implements Logger { public function log(string $msg) { echo $msg; } }); var_dump($app->getLogger()->log("bla bla")); ?>
based on AYAQd
Output for 7.0.0 - 7.2.0
bla blaNULL
Output for 5.3.18 - 5.6.21
Parse error: syntax error, unexpected ':', expecting ';' or '{' in /in/4bYGi on line 9
Process exited with code 255.