3v4l.org

run code in 300+ PHP versions simultaneously
<?php function f($errno, $errstr, $errfile, $errline ) { $args = func_get_args(); print_r($args); return true; } function exception_error_handler($errno, $errstr, $errfile, $errline ) { throw new ErrorException($errstr); } ++$lorem; set_error_handler("exception_error_handler"); ++$foo; set_error_handler("exception_error_handler"); try { preg_match("/foo(+/", null); echo "+valid\n"; } catch (ErrorException $e) { echo "-fail: ", $e->getMessage(), "\n"; } restore_error_handler(); ++$bar; restore_error_handler(); ++$ipsum;
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.7
Warning: Undefined variable $lorem in /in/vXSX1 on line 12 Fatal error: Uncaught ErrorException: Undefined variable $foo in /in/vXSX1:9 Stack trace: #0 /in/vXSX1(16): exception_error_handler(2, 'Undefined varia...', '/in/vXSX1', 16) #1 {main} thrown in /in/vXSX1 on line 9
Process exited with code 255.
Output for 7.0.0 - 7.0.20, 7.1.0 - 7.1.20, 7.2.0 - 7.2.33, 7.3.12 - 7.3.31, 7.4.0 - 7.4.33
Notice: Undefined variable: lorem in /in/vXSX1 on line 12 Fatal error: Uncaught ErrorException: Undefined variable: foo in /in/vXSX1:9 Stack trace: #0 /in/vXSX1(16): exception_error_handler(8, 'Undefined varia...', '/in/vXSX1', 16, Array) #1 {main} thrown in /in/vXSX1 on line 9
Process exited with code 255.
Output for 7.3.32 - 7.3.33
Fatal error: Uncaught ErrorException: Undefined variable: foo in /in/vXSX1:9 Stack trace: #0 /in/vXSX1(16): exception_error_handler(8, 'Undefined varia...', '/in/vXSX1', 16, Array) #1 {main} thrown in /in/vXSX1 on line 9
Process exited with code 255.
Output for 5.3.0 - 5.3.29, 5.4.0 - 5.4.45, 5.5.24 - 5.5.35, 5.6.8 - 5.6.28
Notice: Undefined variable: lorem in /in/vXSX1 on line 12 Fatal error: Uncaught exception 'ErrorException' with message 'Undefined variable: foo' in /in/vXSX1:9 Stack trace: #0 /in/vXSX1(16): exception_error_handler(8, 'Undefined varia...', '/in/vXSX1', 16, Array) #1 {main} thrown in /in/vXSX1 on line 9
Process exited with code 255.
Output for 5.1.0 - 5.1.6, 5.2.0 - 5.2.17
Notice: Undefined variable: lorem in /in/vXSX1 on line 12 Fatal error: Uncaught exception 'ErrorException' with message 'Undefined variable: foo' in /in/vXSX1:9 Stack trace: #0 /in/vXSX1(16): exception_error_handler() #1 {main} thrown in /in/vXSX1 on line 9
Process exited with code 255.
Output for 5.0.4 - 5.0.5
Notice: Undefined variable: lorem in /in/vXSX1 on line 12 Fatal error: Class 'ErrorException' not found in /in/vXSX1 on line 9
Process exited with code 255.
Output for 5.0.0 - 5.0.3
Notice: Undefined variable: lorem in /in/vXSX1 on line 12 Fatal error: Class 'ErrorException' not found in /in/vXSX1 on line 9
Process exited with code 255.
Output for 4.4.2 - 4.4.9
Parse error: syntax error, unexpected T_NEW in /in/vXSX1 on line 9
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 T_NEW in /in/vXSX1 on line 9
Process exited with code 255.
Output for 4.3.2 - 4.3.4
Parse error: parse error in /in/vXSX1 on line 9
Process exited with code 255.

preferences:
206.47 ms | 401 KiB | 316 Q