3v4l.org

run code in 300+ PHP versions simultaneously
<?php print "EVAL WITH PARSE ERROR\n"; try { eval("class C { function foo() }"); } catch (\Throwable $e) { print "CAUGHT [" . get_class($e) . "]: " . $e->getMessage() . "\n"; } print "EVAL WITH EMPTY METHOD\n"; try { eval("class C { function foo(); }"); } catch (\Throwable $e) { print "CAUGHT [" . get_class($e) . "]: " . $e->getMessage() . "\n"; } print "EXECUTION COMPLETED\n";
Output for 8.0.0 - 8.0.30, 8.1.0 - 8.1.28, 8.2.0 - 8.2.18, 8.3.0 - 8.3.6
EVAL WITH PARSE ERROR CAUGHT [ParseError]: syntax error, unexpected token "}", expecting ";" or "{" EVAL WITH EMPTY METHOD Fatal error: Non-abstract method C::foo() must contain body in /in/YY0Wu(13) : eval()'d code on line 1
Process exited with code 255.
Output for 7.0.0 - 7.0.33, 7.1.0 - 7.1.33, 7.2.0 - 7.2.34, 7.3.0 - 7.3.33, 7.4.0 - 7.4.33
EVAL WITH PARSE ERROR CAUGHT [ParseError]: syntax error, unexpected '}', expecting ';' or '{' EVAL WITH EMPTY METHOD Fatal error: Non-abstract method C::foo() must contain body in /in/YY0Wu(13) : eval()'d code on line 1
Process exited with code 255.
Output for 5.3.0 - 5.3.29, 5.4.0 - 5.4.45, 5.5.0 - 5.5.38, 5.6.0 - 5.6.40
EVAL WITH PARSE ERROR Parse error: syntax error, unexpected '}', expecting ';' or '{' in /in/YY0Wu(5) : eval()'d code on line 1 EVAL WITH EMPTY METHOD Fatal error: Non-abstract method C::foo() must contain body in /in/YY0Wu(13) : eval()'d code on line 1
Process exited with code 255.
Output for 5.1.0 - 5.1.6, 5.2.0 - 5.2.17
Warning: Unexpected character in input: '\' (ASCII=92) state=1 in /in/YY0Wu on line 7 Warning: Unexpected character in input: '\' (ASCII=92) state=1 in /in/YY0Wu on line 15 EVAL WITH PARSE ERROR Parse error: syntax error, unexpected '}', expecting ';' or '{' in /in/YY0Wu(5) : eval()'d code on line 1 EVAL WITH EMPTY METHOD Fatal error: Non-abstract method C::foo() must contain body in /in/YY0Wu(13) : eval()'d code on line 1
Process exited with code 255.
Output for 5.0.0 - 5.0.5
Warning: Unexpected character in input: '\' (ASCII=92) state=1 in /in/YY0Wu on line 7 Warning: Unexpected character in input: '\' (ASCII=92) state=1 in /in/YY0Wu on line 15 EVAL WITH PARSE ERROR Parse error: parse error, unexpected '}', expecting '{' or ';' in /in/YY0Wu(5) : eval()'d code on line 1 Fatal error: Class 'Throwable' not found in /in/YY0Wu on line 7
Process exited with code 255.
Output for 4.4.2 - 4.4.9
Parse error: syntax error, unexpected '{' in /in/YY0Wu on line 4
Process exited with code 255.
Output for 4.3.0 - 4.3.1, 4.3.5 - 4.3.11, 4.4.0 - 4.4.1
Parse error: parse error, unexpected '{' in /in/YY0Wu on line 4
Process exited with code 255.
Output for 4.3.2 - 4.3.4
Parse error: parse error in /in/YY0Wu on line 4
Process exited with code 255.

preferences:
337.35 ms | 401 KiB | 468 Q