3v4l.org

run code in 300+ PHP versions simultaneously
<?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'; A::${y[0]}();
Output for 8.2.0 - 8.2.18, 8.3.0 - 8.3.6
Deprecated: Using ${var} in strings is deprecated, use {$var} instead in /in/j577g on line 12 xyzxyzbarbar Fatal error: Uncaught Error: Undefined constant "y" in /in/j577g:23 Stack trace: #0 {main} thrown in /in/j577g on line 23
Process exited with code 255.
Output for 8.0.0 - 8.0.30, 8.1.0 - 8.1.28
xyzxyzbarbar Fatal error: Uncaught Error: Undefined constant "y" in /in/j577g:23 Stack trace: #0 {main} thrown in /in/j577g on line 23
Process exited with code 255.
Output for 7.2.0 - 7.2.33, 7.3.0 - 7.3.33, 7.4.0 - 7.4.33
xyzxyzbarbar Warning: Use of undefined constant y - assumed 'y' (this will throw an Error in a future version of PHP) in /in/j577g on line 23 Fatal error: Uncaught Error: Function name must be a string in /in/j577g:23 Stack trace: #0 {main} thrown in /in/j577g on line 23
Process exited with code 255.
Output for 7.0.0 - 7.0.33, 7.1.0 - 7.1.33
xyzxyzbarbar Notice: Use of undefined constant y - assumed 'y' in /in/j577g on line 23 Fatal error: Uncaught Error: Function name must be a string in /in/j577g:23 Stack trace: #0 {main} thrown in /in/j577g on line 23
Process exited with code 255.
Output for 5.6.0 - 5.6.40
xyzxyzbarbar Notice: Use of undefined constant y - assumed 'y' in /in/j577g on line 23 Fatal error: Function name must be a string in /in/j577g on line 23
Process exited with code 255.
Output for 5.5.0 - 5.5.38
Parse error: syntax error, unexpected '[' in /in/j577g on line 23
Process exited with code 255.

preferences:
204.33 ms | 401 KiB | 330 Q