3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Foo { const Bar = 123; static $Bar = 456; } function tryEval(string $code) { $foo = new Foo; try { eval($code); } catch(Throwable $e) { echo $e, "\n"; } echo "\n"; } tryEval('echo "{$foo::$Bar}\n";'); tryEval('echo "{$foo::Bar}\n";'); tryEval('echo "{$foo::class}\n";');
Output for 8.4.1 - 8.4.14
456 ParseError: syntax error, unexpected token "}", expecting "->" or "?->" or "[" in /in/hTnNv(11) : eval()'d code:1 Stack trace: #0 /in/hTnNv(19): tryEval('echo "{$foo::Ba...') #1 {main} ParseError: syntax error, unexpected token "}", expecting "->" or "?->" or "[" in /in/hTnNv(11) : eval()'d code:1 Stack trace: #0 /in/hTnNv(20): tryEval('echo "{$foo::cl...') #1 {main}
Output for 8.0.1 - 8.0.30, 8.1.0 - 8.1.33, 8.2.0 - 8.2.29, 8.3.0 - 8.3.27
456 ParseError: syntax error, unexpected token "}", expecting "->" or "?->" or "{" or "[" in /in/hTnNv(11) : eval()'d code:1 Stack trace: #0 /in/hTnNv(19): tryEval('echo "{$foo::Ba...') #1 {main} ParseError: syntax error, unexpected token "}", expecting "->" or "?->" or "{" or "[" in /in/hTnNv(11) : eval()'d code:1 Stack trace: #0 /in/hTnNv(20): tryEval('echo "{$foo::cl...') #1 {main}

preferences:
109.12 ms | 409 KiB | 5 Q