3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php function struct(string $name, array $class) { $class = json_encode($class); define($name, $class); } function create($class) { $object = (array) json_decode($class); return $object; } function call(array &$class, string $member, ...$args) { if(!isset($class[$member])) exit($member.' is not a member of the class.'); else { if(!isset($args[0])) call_user_func([$class, $member], $class); else call_user_func([$class, $member], $class, $args); } } call([ 'foo' => function (&$this) { echo('Hello World!'); } ], 'foo');
based on NJ1EM
Output for 7.0.0 - 7.0.1
Fatal error: Only variables can be passed by reference in /in/jhOMU on line 21
Process exited with code 255.
Output for 5.6.8 - 5.6.16
Fatal error: Only variables can be passed by reference in /in/jhOMU on line 22
Process exited with code 255.
Output for 5.4.11 - 5.5.30
Parse error: syntax error, unexpected '.', expecting '&' or variable (T_VARIABLE) in /in/jhOMU on line 10
Process exited with code 255.
Output for 5.3.21 - 5.3.29
Parse error: syntax error, unexpected '.', expecting '&' or T_VARIABLE in /in/jhOMU on line 10
Process exited with code 255.