3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php $obj = new stdClass(); $data = ["foo"=>"bar"]; $key = "foo"; $obj->data = $data; echo "{$obj->{ ${'data'}[$key] }}\n"; echo "{$obj->{ ${data}[$key] }}\n";
based on I8pOS
Output for 7.2.0
Notice: Undefined property: stdClass::$bar in /in/7E6Q8 on line 6 Warning: Use of undefined constant data - assumed 'data' (this will throw an Error in a future version of PHP) in /in/7E6Q8 on line 7 Notice: Undefined property: stdClass::$bar in /in/7E6Q8 on line 7
Output for 5.4.11 - 7.1.10
Notice: Undefined property: stdClass::$bar in /in/7E6Q8 on line 6 Notice: Use of undefined constant data - assumed 'data' in /in/7E6Q8 on line 7 Notice: Undefined property: stdClass::$bar in /in/7E6Q8 on line 7
Output for 5.3.21 - 5.3.29
Parse error: syntax error, unexpected '[' in /in/7E6Q8 on line 3
Process exited with code 255.