3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php interface Logger { public function log($message); } class Application { protected $logger; public function setLogger(Logger $logger) { $this->logger = $logger; } public function doTask() { $this->logger->log('test data'); } } $app = new Application(); $app->setLogger(new class implements Logger { public function log($message) { var_dump($message); } }); $app->doTask();
based on NS1Pn
Output for 7.0.0 - 7.2.0
string(9) "test data"
Output for 5.4.11 - 5.6.28
Parse error: syntax error, unexpected 'class' (T_CLASS) in /in/3vTgm on line 25
Process exited with code 255.
Output for 5.3.21 - 5.3.29
Parse error: syntax error, unexpected T_CLASS in /in/3vTgm on line 25
Process exited with code 255.