3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php function _(array &$class, string $member, ...$args) { if(!isset($class[$member])) exit($member.' is not a member of the class.'); else { if(!is_callable($class[$member])) return $class[$member]; else { if(!isset($args[0])) $class[$member]($class); else $class[$member]($class, $args); } } } function __(array $class, ...$args) { $obj = $class; if(isset($class['__construct']) { if(isset($args[0])) $obj['__construct']($obj, $args); else $obj['__construct']($obj); } return $obj; } $obj = [ 'foo' => 'Hello', 'bar' => function (&$this) { $this['foo'] = ' World!'; } ]; echo($obj['foo']); _($obj, 'bar'); echo($obj['foo']);
based on 57bCM
Output for 7.0.0 - 7.0.1
Parse error: syntax error, unexpected '{' in /in/2RD75 on line 14
Process exited with code 255.
Output for 5.6.8 - 5.6.16
Fatal error: Cannot redeclare _() in /in/2RD75 on line 11
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/2RD75 on line 2
Process exited with code 255.
Output for 5.3.21 - 5.3.29
Parse error: syntax error, unexpected '.', expecting '&' or T_VARIABLE in /in/2RD75 on line 2
Process exited with code 255.