3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php class myClass { } $obj = new myClass; $obj->color = function( $item ){ $arr = ["rose"=>"red", "violet"=>"blue", "grass"=>"green"]; return $arr[$item]; }; $flowers = [0=>"rose",1=>"violet"]; foreach ($flowers as $key => $flower){ echo "{$flower}s are ",($obj->color)($flower), echo ($key == 0)? ",\n" : "...\n"; }
based on S3SH1
Output for 7.0.0 - 7.0.2
Parse error: syntax error, unexpected 'echo' (T_ECHO) in /in/3oT1q on line 20
Process exited with code 255.
Output for 5.4.11 - 5.6.17
Parse error: syntax error, unexpected '(', expecting ',' or ';' in /in/3oT1q on line 19
Process exited with code 255.
Output for 5.3.21 - 5.3.29
Parse error: syntax error, unexpected '[' in /in/3oT1q on line 8
Process exited with code 255.