3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php $obj = new stdClass(); $obj->bar = "xyz"; $data = array("foo" => "bar"); $key = "foo"; // echo $obj->${data[$key]}; syntax error echo $obj->{$data[$key]}; $member = $data[$key]; echo $obj->$member; echo "{$obj->${data[$key]}}"; echo "{$obj->{$data[$key]}}";
based on rouns
Output for 7.2.0
xyzxyz Warning: Use of undefined constant data - assumed 'data' (this will throw an Error in a future version of PHP) in /in/7Fboa on line 12 Warning: Illegal string offset 'foo' in /in/7Fboa on line 12 Notice: Undefined variable: d in /in/7Fboa on line 12 Notice: Undefined property: stdClass::$ in /in/7Fboa on line 12 xyz
Output for 7.1.0 - 7.1.10
xyzxyz Notice: Use of undefined constant data - assumed 'data' in /in/7Fboa on line 12 Warning: Illegal string offset 'foo' in /in/7Fboa on line 12 Notice: Undefined variable: d in /in/7Fboa on line 12 Notice: Undefined property: stdClass::$ in /in/7Fboa on line 12 xyz
Output for 7.0.0 - 7.0.20
xyzxyz Notice: Use of undefined constant data - assumed 'data' in /in/7Fboa on line 12 Warning: Illegal string offset 'foo' in /in/7Fboa on line 12 Notice: Undefined variable: d in /in/7Fboa on line 12 Fatal error: Uncaught Error: Cannot access empty property in /in/7Fboa:12 Stack trace: #0 {main} thrown in /in/7Fboa on line 12
Process exited with code 255.
Output for 5.6.8 - 5.6.28
xyzxyz Notice: Use of undefined constant data - assumed 'data' in /in/7Fboa on line 12 Warning: Illegal string offset 'foo' in /in/7Fboa on line 12 Notice: Undefined variable: d in /in/7Fboa on line 12 Fatal error: Cannot access empty property in /in/7Fboa on line 12
Process exited with code 255.
Output for 5.3.21 - 5.5.35
Parse error: syntax error, unexpected '[' in /in/7Fboa on line 12
Process exited with code 255.