3v4l.org

run code in 300+ PHP versions simultaneously
<?php phpversion() >= "7.0.1" or die(); $obj = new stdClass(); $obj->bar = "xyz"; $data = array("foo" => "bar"); $key = "foo"; // the bad: try { echo $obj->${data[$key]}; // syntax error } catch (Error $e){ echo $e->getMessage(),"\n"; } /* PHP 7.0.1+ Notice: Use of undefined constant data - assumed 'data' in /in/qa1C0 on line 11 Warning: Illegal string offset 'foo' in /in/qa1C0 on line 11 Notice: Undefined variable: d in /in/qa1C0 on line 11 Cannot access empty property */

preferences:
32.6 ms | 402 KiB | 5 Q