3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php class foo { public $bar = 'baz'; } $x = 'bar'; $o = new foo(); echo $o->$x; echo $o->{$x}; echo $o[$x]; echo get_object_vars($o)[$x);
Output for 5.4.0 - 5.4.15
Parse error: syntax error, unexpected ')', expecting ']' in /in/cDqu8 on line 12
Process exited with code 255.
Output for 5.3.0 - 5.3.25
Parse error: syntax error, unexpected '[', expecting ',' or ';' in /in/cDqu8 on line 12
Process exited with code 255.