/*
自定义错误报告程序
trigger_error 触发程序的发生
set_error_handler 的参数定义了哪个函数来打印相关的信息
myErrHandler 打印相关的信息
*/
// set the error reporting level for this script
error_reporting("2047"); // 这个是报告所有的错误
function myErrHandler($errno, $errstr, $errfile, $errline, $errcontext) {
$info = "";
if (isset($_SERVER)) {
$info = "request_uri=" . $_SERVER['REQUEST_URI'] . " http_user_agent=" . $_SERVER['HTTP_USER_AGENT'] . " remote_addr=" . $_SERVER['REMOTE_ADDR'];
}
$errstr = trim($errstr);
echo "errfile: $errfile <br> errstr: $errstr <br>errline: $errline <br>info:$info<hr>";
}
set_error_handler("myErrHandler");
trigger_error("tu_db_mysql_query() failed", "1");