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 VMCIX
Output for 7.0.0 - 7.2.0
myClass...violets are bluish ...violets are Fatal error: Uncaught Error: Call to undefined method myClass::color() in /in/PmQNa:21 Stack trace: #0 {main} thrown in /in/PmQNa on line 21
Process exited with code 255.
Output for 5.4.11 - 5.6.28
myClass...violets are bluish ...violets are Fatal error: Call to undefined method myClass::color() in /in/PmQNa on line 21
Process exited with code 255.
Output for 5.3.21 - 5.3.29
Parse error: syntax error, unexpected '[' in /in/PmQNa on line 14
Process exited with code 255.