3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php class RenderEngine { private $blocks = []; public function block($name, $callback) { $this->blocks[$name] = $callback; } public function draw($name, array $args) { call_user_func_array($this->blocks[$name], $args); } } $t = new RenderEngine(); ?> <?php $t->block('article', function ($article) { ?> <?=$article;?> <?php }); ?> <?=$t->draw('article', ['hello']);?>
based on kE8Y4
Output for 5.4.0 - 7.2.0
hello
Output for 5.3.19 - 5.3.29
Parse error: syntax error, unexpected '[' in /in/KBafI on line 4
Process exited with code 255.