无详细内容 无 ?php/** * 异常处理 * @return void */function debug_user_handler($errno, $errstr, $errfile, $errline, $errcontext){ob_start();debug_print_backtrace();$trace = ob_get_contents();ob_end_clean();$data = array(isset($_SERVER['REQUE
<?php /** * 异常处理 * @return void */ function debug_user_handler($errno, $errstr, $errfile, $errline, $errcontext) { ob_start(); debug_print_backtrace(); $trace = ob_get_contents(); ob_end_clean(); $data = array( isset($_SERVER['REQUEST_URI']) ? $_SERVER['REQUEST_URI'] : "", date("Y-m-d H:i:s"), "错误号{$errno}, 文件:{$errfile} 行号: {$errline}", $errstr, $trace); trigger_error(implode("\n", $data) . '(' . $errno . ')'); } // 可以设置不同异常等级 set_error_handler('debug_user_handler', E_USER_NOTICE|E_USER_WARNING); // 测试 function test_handler() { $x = mt_rand(0, 100); echo "x=$x\n"; if ($x > 50) { trigger_error("x great than 50", E_USER_NOTICE); } else { trigger_error("x less than 50", E_USER_WARNING); } } test_handler();