3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php set_error_handler(function ($errno, $errstr, $errfile, $errline) { $namespace = 'ajf\ErrorExceptions\Dynamic'; $className = preg_replace('/[^a-zA-Z0-9]/g', '', preg_replace('/\:.*$/g', '', implode('', explode(' ', ucwords($errstr))))); $fullClassName = $namespace . '\\' . $className; if (!class_exists($fullClassName)) { eval("namespace $namespace { class $className extends \ErrorException {} }"); } throw new $fullClassName($errstr, 0, $errno, $errfile, $errline); }); try { $foo = 1/0; } catch (ajf\ErrorExceptions\Dynamic\DivisionByZero $e) { echo "ba-da-bing, ba-da-boom: I caught a $e!\n"; } try { $repent = sin("123abc"); } catch (ajf\ErrorExceptions\Dynamic\ANonWellFormedNumericValueEncountered $e) { echo "praise be to zend_is_numeric_string_ex: $e"; } try { $empty = []; $void = $empty["soul"]; } catch (ajf\ErrorExceptions\Dynamic\UndefinedOffset $e) { echo "not even the colon can defeat me: $e"; }
based on uYQ1n
Output for 7.0.0 - 7.2.0
Warning: preg_replace(): Unknown modifier 'g' in /in/jqjAl on line 5 Warning: preg_replace(): Unknown modifier 'g' in /in/jqjAl on line 5 Parse error: syntax error, unexpected 'extends' (T_EXTENDS), expecting identifier (T_STRING) in /in/jqjAl(8) : eval()'d code on line 1
Process exited with code 255.
Output for 5.4.11 - 5.6.28
Warning: preg_replace(): Unknown modifier 'g' in /in/jqjAl on line 5 Warning: preg_replace(): Unknown modifier 'g' in /in/jqjAl on line 5 Parse error: syntax error, unexpected 'extends' (T_EXTENDS), expecting identifier (T_STRING) in /in/jqjAl(8) : eval()'d code on line 1 Fatal error: Class 'ajf\ErrorExceptions\Dynamic\' not found in /in/jqjAl on line 11
Process exited with code 255.
Output for 5.3.21 - 5.3.29
Parse error: syntax error, unexpected '[' in /in/jqjAl on line 27
Process exited with code 255.