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!';

preferences:
55.23 ms | 402 KiB | 5 Q