3v4l.org

run code in 300+ PHP versions simultaneously
<?php class A { static function hello(){ return "Hello World\n"; } } $y[0] = 'hello'; echo "{A::${y[0]}()}"; // echo A::${y[0]}();
Output for 8.2.0 - 8.2.18, 8.3.0 - 8.3.7
Deprecated: Using ${var} in strings is deprecated, use {$var} instead in /in/B5nLf on line 11 {A::hello()} Fatal error: Uncaught Error: Undefined constant "y" in /in/B5nLf:12 Stack trace: #0 {main} thrown in /in/B5nLf on line 12
Process exited with code 255.
Output for 8.0.0 - 8.0.30, 8.1.0 - 8.1.28
{A::hello()} Fatal error: Uncaught Error: Undefined constant "y" in /in/B5nLf:12 Stack trace: #0 {main} thrown in /in/B5nLf on line 12
Process exited with code 255.
Output for 7.2.0 - 7.2.33, 7.3.16 - 7.3.33, 7.4.0 - 7.4.33
{A::hello()} Warning: Use of undefined constant y - assumed 'y' (this will throw an Error in a future version of PHP) in /in/B5nLf on line 12 Fatal error: Uncaught Error: Function name must be a string in /in/B5nLf:12 Stack trace: #0 {main} thrown in /in/B5nLf on line 12
Process exited with code 255.
Output for 7.0.0 - 7.0.20, 7.1.0 - 7.1.20
{A::hello()} Notice: Use of undefined constant y - assumed 'y' in /in/B5nLf on line 12 Fatal error: Uncaught Error: Function name must be a string in /in/B5nLf:12 Stack trace: #0 {main} thrown in /in/B5nLf on line 12
Process exited with code 255.
Output for 5.6.8 - 5.6.21
{A::hello()} Notice: Use of undefined constant y - assumed 'y' in /in/B5nLf on line 12 Fatal error: Function name must be a string in /in/B5nLf on line 12
Process exited with code 255.
Output for 5.5.24 - 5.5.35
Parse error: syntax error, unexpected '[' in /in/B5nLf on line 12
Process exited with code 255.

preferences:
128.4 ms | 401 KiB | 182 Q