3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php class E{function r($e, $l){$this->e[$e][] = $l} function d($e){foreach ($this->e[$e] as $l){$l->o();}}} class Listener { function o() { echo 'hello'; } } $listener = new Listener(); $eventDispatcher = new E(); $eventDispatcher->r('event1', $listener); $eventDispatcher->r('event1', $listener); $eventDispatcher->r('event2', $listener); $eventDispatcher->d('event1');
Output for 5.3.0 - 5.4.27
Parse error: syntax error, unexpected '}' in /in/hCrdo on line 2
Process exited with code 255.