3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php convertPhpErrorsToExceptions(); $array = ['hi' => 'dsa']; echo $array['unknown']; function convertPhpErrorsToExceptions() { static $isNotLoaded = true; if ($isNotLoaded) { set_error_handler('phpErrorToException'); $isNotLoaded = false; } } function phpErrorToException($severity, $message, $filename, $lineno) { if (error_reporting() & $severity) { throw new \ErrorException($message, 0, $severity, $filename, $lineno); } }
based on 7MSlR
Output for 7.0.0 - 7.2.0
Fatal error: Uncaught ErrorException: Undefined index: unknown in /in/emBU0:5 Stack trace: #0 /in/emBU0(5): phpErrorToException(8, 'Undefined index...', '/in/emBU0', 5, Array) #1 {main} thrown in /in/emBU0 on line 5
Process exited with code 255.
Output for 5.4.11 - 5.6.28
Fatal error: Uncaught exception 'ErrorException' with message 'Undefined index: unknown' in /in/emBU0:5 Stack trace: #0 /in/emBU0(5): phpErrorToException(8, 'Undefined index...', '/in/emBU0', 5, Array) #1 {main} thrown in /in/emBU0 on line 5
Process exited with code 255.
Output for 5.3.21 - 5.3.29
Parse error: syntax error, unexpected '[' in /in/emBU0 on line 4
Process exited with code 255.