3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?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!';
based on AVjXY
Output for 5.6.0 - 5.6.30, hhvm-3.15.4, 7.0.0 - 7.3.0rc3
hello!true!false!