3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php class myClass { public function __construct(){ echo __CLASS__; } } $obj = new myClass; $flower = "violet"; $obj->clr = "bluish"; $obj->color = function()use($flower){ $arr = ["rose"=>"red", "violet"=>"blue", "grass"=>"green"]; return $arr[$flower]; }; echo "...{$flower}s are ",$obj->clr,"\n"; echo "...{$flower}s are ",($obj->color)();
based on ZkFMG
Output for 7.0.0 - 7.2.0
myClass...violets are bluish ...violets are blue
Output for 5.4.11 - 5.6.28
Parse error: syntax error, unexpected '(', expecting ',' or ';' in /in/VMCIX on line 21
Process exited with code 255.
Output for 5.3.21 - 5.3.29
Parse error: syntax error, unexpected '[' in /in/VMCIX on line 14
Process exited with code 255.