3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php interface ListenerAggregate {} class EM { public function attach(callable $listener){ if($listener instanceof ListenerAggregate){ // this is indeed an aggregate! } } } class SomeAggregateListener implements ListenerAggregate { public function __invoke() { // look ma, I'm a callable! } } $em = new EM; $em->attach(function(){}); $aggregate = new SomeAggregateListener; $em->attach($aggregate);
Output for 5.4.0 - 5.4.21
Parse error: syntax error, unexpected '$em' (T_VARIABLE), expecting function (T_FUNCTION) in /in/G5q2X on line 16
Process exited with code 255.
Output for 5.3.0 - 5.3.27
Parse error: syntax error, unexpected T_VARIABLE, expecting T_FUNCTION in /in/G5q2X on line 16
Process exited with code 255.