3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php $obj = new stdClass; $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 ucfirst("{$flower}s are "); echo $obj->color($flower); echo ($key == 0)? ",\n" : " ...\n"; }
based on scC8X
Output for 7.0.0 - 7.2.0
Roses are Fatal error: Uncaught Error: Call to undefined method stdClass::color() in /in/rPJL2:17 Stack trace: #0 {main} thrown in /in/rPJL2 on line 17
Process exited with code 255.
Output for 5.5.0 - 5.6.25
Roses are Fatal error: Call to undefined method stdClass::color() in /in/rPJL2 on line 17
Process exited with code 255.