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; } }); $app->getLogger()->log("bla bla"); ?>
based on 4bYGi
Output for 7.0.0 - 7.2.0
bla bla
Output for 5.3.18 - 5.6.28
Parse error: syntax error, unexpected ':', expecting ';' or '{' in /in/3rsvr on line 9
Process exited with code 255.