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