3v4l.org

run code in 300+ PHP versions simultaneously
<?php class RenderEngine { private $blocks = []; public function block($name, $callback) { $this->blocks[$name] = $callback; } public function draw($name, array $args) { call_user_func_args($this->blocks[$name], $args); } } $t = new RenderEngine(); ?> <?php $t->block('article', function ($article): ?> <?=$article;?> <?php endfunction;); ?> <?=$t->draw('article', ['hello']);?>
Output for 5.4.0 - 5.4.45, 5.5.24 - 5.5.30, 5.6.7 - 5.6.14
Parse error: syntax error, unexpected ':', expecting '{' in /in/Eq9OR on line 18
Process exited with code 255.

preferences:
185.92 ms | 940 KiB | 68 Q