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 "${data[$key]}"; echo "{$data[$key]}"; class A { static function hello(){ echo "Hello World\n"; } } $y[0] = 'hello'; echo A::${y[0]};
based on j577g
Output for 7.2.0
xyzxyzbarbar Warning: Use of undefined constant y - assumed 'y' (this will throw an Error in a future version of PHP) in /in/8mvtY on line 23 Fatal error: Uncaught Error: Access to undeclared static property: A::$y in /in/8mvtY:23 Stack trace: #0 {main} thrown in /in/8mvtY on line 23
Process exited with code 255.
Output for 7.0.0 - 7.1.10
xyzxyzbarbar Notice: Use of undefined constant y - assumed 'y' in /in/8mvtY on line 23 Fatal error: Uncaught Error: Access to undeclared static property: A::$y in /in/8mvtY:23 Stack trace: #0 {main} thrown in /in/8mvtY on line 23
Process exited with code 255.
Output for 5.6.8 - 5.6.28
xyzxyzbarbar Notice: Use of undefined constant y - assumed 'y' in /in/8mvtY on line 23 Fatal error: Access to undeclared static property: A::$y in /in/8mvtY on line 23
Process exited with code 255.
Output for 5.3.21 - 5.5.35
Parse error: syntax error, unexpected '[' in /in/8mvtY on line 23
Process exited with code 255.