3v4l.org

run code in 300+ PHP versions simultaneously
<?php function event($n, $h = null) { static $e = []; return $h ? $e[$n][] = $h : (isset($e[$n] ? array_walk($e[$n], function($e) {$e();}) : 0); } event('hello', function () { echo 'hello!'; }); echo event('hello') ? 'true!' : 'false!'; echo event('world') ? 'true!' : 'false!';
Output for 7.0.0 - 7.0.19, 7.1.0 - 7.1.5
Parse error: syntax error, unexpected ';' in /in/AVjXY on line 2
Process exited with code 255.

preferences:
202.97 ms | 1395 KiB | 33 Q