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()); ?>
based on sD6DL
Output for 7.0.0 - 7.2.0
object(class@anonymous)#2 (0) { }
Output for 5.4.0 - 5.6.28
Parse error: syntax error, unexpected ':', expecting ';' or '{' in /in/AYAQd on line 9
Process exited with code 255.