Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p><code>set_error_handler</code> allows you to specify a user-defined error handling function for deciding what to do with certain (but only non-fatal) errors. You can then handle specific types of errors in any fashion you deem necessary, for example notifying a system administrator via email, or saving to a specific log file. See: <a href="http://php.net/manual/en/function.set-error-handler.php" rel="nofollow noreferrer">PHP Doc</a> for further details. </p> <p>With regards to your request you could the following approach:</p> <pre><code>function myErrorHandler($errno, $errstr, $errfile, $errline) { if (!(error_reporting() &amp; $errno)) { // This error code is not included in error_reporting return; } switch ($errno) { case E_USER_ERROR: case E_ERROR: case E_COMPILE_ERROR: echo "&lt;b&gt;My ERROR&lt;/b&gt; [$errno] $errstr&lt;br /&gt;\n"; echo " Fatal error on line $errline in file $errfile"; echo ", PHP " . PHP_VERSION . " (" . PHP_OS . ")&lt;br /&gt;\n"; echo "Aborting...&lt;br /&gt;\n"; emailErrorFunction($errno,$erstr,$errfile,$errline); exit(1); break; default: echo "Unknown error type: [$errno] $errstr&lt;br /&gt;\n"; break; } /* Don't execute PHP internal error handler */ return true; } // Report all errors error_reporting(E_ALL); // User a custom error handler to print output set_error_handler( 'myErrorHandler' ); </code></pre> <p>As that error-handling does not work for Fatal Errors (Parse errors, undefined functions etc.), you need to tape this with <a href="http://php.net/register_shutdown_function" rel="nofollow noreferrer"><code>register_shutdown_function</code></a> as outlined in a related question:</p> <ul> <li><a href="https://stackoverflow.com/q/277224/367456">How do I catch a PHP Fatal Error</a></li> </ul>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload