Summary
I have school management system which is used in different institute. if any person see error on any page than it click on report button than all the errors store in table where i can see what kind of error comes against institute I want to store all the php errors warning etc in variable but its show empty.
If variable store errors and warning than it will show like this.
Problem
No error store in global array.
Code
ini_get(0);
set_error_handler("errorHandler");
register_shutdown_function("shutdownHandler");
function errorHandler($error_level, $error_message, $error_file,
$error_line, $error_context)
{
$error = " Msg:" . $error_message . " file:" . $error_file . " ln:" .
$error_line;
switch ($error_level) {
case E_ERROR:
case E_CORE_ERROR:
case E_COMPILE_ERROR:
case E_PARSE:
mylog($error, "fatal");
break;
case E_USER_ERROR:
case E_RECOVERABLE_ERROR:
mylog($error, "error");
break;
case E_WARNING:
case E_CORE_WARNING:
case E_COMPILE_WARNING:
case E_USER_WARNING:
mylog($error, "warn");
break;
case E_NOTICE:
case E_USER_NOTICE:
mylog($error, "info");
break;
case E_STRICT:
mylog($error, "debug");
break;
default:
mylog($error, "warn");
}
}
Global Array
$custom_error show empty.
global $custom_error;
$custom_error = array();
function mylog($error, $errlvl)
{
// error_log($error);
// echo '<p><b>'.$error.'<b></p>';
$custom_error = $error
}
print_r($custom_error); //Show empty
if($custom_error){
echo '<button> Report </button>';
}