自定義 php 錯誤捕獲代碼
<?php /**
- @Author: yangyulong
- @Date: 2015-12-28 22:09:22
- @Last Modified by: yangyulong
- @Last Modified time: 2015-12-28 22:48:49 */ error_reporting(0); //注冊錯誤捕捉函數 register_shutdown_function('jd_fatal_error');
//注冊錯誤處理函數 set_error_handler('jd_error_handler');
function jd_fatal_error(){ if ($e = error_get_last()) { switch ($e['type']) { case E_ERROR: case E_PARSE: case E_CORE_ERROR: case E_COMPILE_ERROR: case E_USER_ERROR: //所有測錯誤類型都用下面的函數同意捕獲 jd_error_handler($e['type'], $e['message'], $e['file'], $e['line']); break; } } }
/**
- 捕獲錯誤的函數 *
- @method jd_error_handler *
- @param [type] $type [description]
- @param [type] $message [description]
- @param [type] $file [description]
- @param [type] $line [description] *
- @return [type] [description] */ function jd_error_handler($type, $message, $file, $line){ echo '<b>'.$type.':'.$message.' in '.$file.' on '.$line. ' line .</b><br />'; }
print_r(xx());
// print_r(debug_backtrace()); // print_r(debug_print_backtrace());</pre>
本文由用戶 jopen 自行上傳分享,僅供網友學習交流。所有權歸原作者,若您的權利被侵害,請聯系管理員。
轉載本站原創文章,請注明出處,并保留原始鏈接、圖片水印。
本站是一個以用戶分享為主的開源技術平臺,歡迎各類分享!