3v4l.org

run code in 300+ PHP versions simultaneously
<?php function bar() { echo "da blyaaa\n"; } $bar = function() { echo "voobshe ohuet\n"; }; class Foo { public const bar = 'bar'; public static string $bar = 'bar'; public function bar(): string { return 'bar'; } } $foo = new Foo; echo "1) This is {Foo::$bar}\n"; echo "2) This is {$foo::$bar()}\n"; echo "3) This is {Foo::bar}\n"; echo "4) This is {Foo->bar()}\n"; echo "5) This is {$foo->bar()}\n"; echo "6) This is ${Foo::bar}\n"; echo "7) This is ${Foo::$bar}\n"; echo "8) This is {$foo::bar()}\n";
Output for 8.2.0 - 8.2.19, 8.3.0 - 8.3.7
Deprecated: Using ${expr} (variable variables) in strings is deprecated, use {${expr}} instead in /in/QBVVf on line 27 Deprecated: Using ${expr} (variable variables) in strings is deprecated, use {${expr}} instead in /in/QBVVf on line 28 Fatal error: Uncaught Error: Object of class Closure could not be converted to string in /in/QBVVf:22 Stack trace: #0 {main} thrown in /in/QBVVf on line 22
Process exited with code 255.
Output for 8.0.1 - 8.0.30, 8.1.0 - 8.1.28
Fatal error: Uncaught Error: Object of class Closure could not be converted to string in /in/QBVVf:22 Stack trace: #0 {main} thrown in /in/QBVVf on line 22
Process exited with code 255.
Output for 7.2.34
Parse error: syntax error, unexpected 'string' (T_STRING), expecting function (T_FUNCTION) or const (T_CONST) in /in/QBVVf on line 13
Process exited with code 255.

preferences:
97.92 ms | 401 KiB | 92 Q