Outputting all PHP errors to database not error_log

☆樱花仙子☆ 提交于 2019-11-26 20:48:20

I don't think it can be done without building an own error handler, but technically, that is the one global change you're looking for.

Modified example from the manual:

function myErrorHandler($errno, $errstr, $errfile, $errline)
{
     // you'd have to import or set up the connection here 
     mysql_query("INSERT INTO error_log (number, string, file, line) ".
                 "VALUES .....");         

    /* Don't execute PHP internal error handler */
    return true;
}

then

// set to the user defined error handler
$old_error_handler = set_error_handler("myErrorHandler");

It looks like the php function set_error_handler might do what you're looking for. In the first example you can add some mysql inserts to write your errors to a database.

http://www.php.net/manual/en/function.set-error-handler.php

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!