3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php $obj = new stdClass(); $obj->bar = "xyz"; $data = array("foo" => "bar"); $key = "foo"; // the good: without and within a string echo $obj->{$data[$key]}; echo "{$obj->{$data[$key]}}"; // the bad: try { echo $obj->${data[$key]}; // syntax error } catch (Error $e){ echo $e->getMessage(),"\n"; } // complex curly brace syntax: without and within a string echo $obj->{${'data'}[$key]}; echo "{$obj->{${'data'}[$key]}}";
based on upm4G
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/J6MqJ on line 14 Warning: Illegal string offset 'foo' in /in/J6MqJ on line 14 Notice: Undefined variable: d in /in/J6MqJ on line 14 Notice: Undefined property: stdClass::$ in /in/J6MqJ on line 14 xyzxyz
Output for 7.1.0 - 7.1.10
xyzxyz Notice: Use of undefined constant data - assumed 'data' in /in/J6MqJ on line 14 Warning: Illegal string offset 'foo' in /in/J6MqJ on line 14 Notice: Undefined variable: d in /in/J6MqJ on line 14 Notice: Undefined property: stdClass::$ in /in/J6MqJ on line 14 xyzxyz
Output for 7.0.0 - 7.0.20
xyzxyz Notice: Use of undefined constant data - assumed 'data' in /in/J6MqJ on line 14 Warning: Illegal string offset 'foo' in /in/J6MqJ on line 14 Notice: Undefined variable: d in /in/J6MqJ on line 14 Cannot access empty property xyzxyz
Output for 5.6.8 - 5.6.28
xyzxyz Notice: Use of undefined constant data - assumed 'data' in /in/J6MqJ on line 14 Warning: Illegal string offset 'foo' in /in/J6MqJ on line 14 Notice: Undefined variable: d in /in/J6MqJ on line 14 Fatal error: Cannot access empty property in /in/J6MqJ on line 14
Process exited with code 255.
Output for 5.3.21 - 5.5.35
Parse error: syntax error, unexpected '[' in /in/J6MqJ on line 14
Process exited with code 255.