How would I do the following as a plugin? Im feeling dumb today.
<?php
function error_handler( $errno, $errstr, $errfile, $errline )
{
$html = '<script type="text/javascript">';
$html .= "console.error('PHP (line: %s) %s | %s');";
$html .= '</script>';
printf( $html, $errline, $errstr, addslashes($errfile) );
return true;
}
error_reporting(E_ALL);
set_error_handler("error_handler");
?>
-
MODX Staff
- 10,725 Posts
First, put your function in an include_once or wrap it in if (!function_exists(’your_error_handler_function’)); though this is not absolutely necessary, it’s good practice none-the-less.
Then, simply register that code in a plugin for OnWebPageInit. That should do it, though I’ve never tried this in 0.9.x so I cannot guarantee it will work. In Revolution, you can provide your own error_handler class and specify it via System Settings, as well as override it in Context Settings; this will then be used as soon as a context is initialized, no plugin necessary.