3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php function f($errno, $errstr, $errfile, $errline ) { echo $errno, ": ", $errstr, " in ", $errfile, " on ", $errline, "\n"; return true; } function exception_error_handler($errno, $errstr, $errfile, $errline ) { throw new ErrorException($errstr); } ++$lorem; set_error_handler('f'); ++$ipsum; /* set_error_handler(function ($errno, $errstr, $errfile, $errline) { echo $errno, ": ", $errstr, " in ", $errfile, " on ", $errline, "\n"; return true; }); ++$dolor; */ 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(); /* ++$sit; restore_error_handler(); */ ++$amet; restore_error_handler(); ++$consectepture;
Output for 5.1.0 - 7.1.0
Notice: Undefined variable: lorem in /in/XIc7s on line 11 8: Undefined variable: ipsum in /in/XIc7s on 15 -fail: preg_match(): Compilation failed: nothing to repeat at offset 4 8: Undefined variable: amet in /in/XIc7s on 42 Notice: Undefined variable: consectepture in /in/XIc7s on line 46
Output for 5.0.4 - 5.0.5
Notice: Undefined variable: lorem in /in/XIc7s on line 11 8: Undefined variable: ipsum in /in/XIc7s on 15 Fatal error: Class 'ErrorException' not found in /in/XIc7s on line 8
Process exited with code 255.
Output for 5.0.0 - 5.0.3
Notice: Undefined variable: lorem in /in/XIc7s on line 11 8: Undefined variable: ipsum in /in/XIc7s on 15 Fatal error: Class 'ErrorException' not found in /in/XIc7s on line 8
Process exited with code 255.
Output for 4.4.2 - 4.4.9
Parse error: syntax error, unexpected T_NEW in /in/XIc7s on line 8
Process exited with code 255.
Output for 4.3.0 - 4.3.1, 4.3.5 - 4.4.1
Parse error: parse error, unexpected T_NEW in /in/XIc7s on line 8
Process exited with code 255.
Output for 4.3.2 - 4.3.4
Parse error: parse error in /in/XIc7s on line 8
Process exited with code 255.