Custom php error catching code, register_shutdown_function(), set_error_handler(
Release: 2016-07-25 08:45:57
Original
1611 people have browsed it
Customized php error catching code, register_shutdown_function(), set_error_handler()
- /**
- * @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 error catching function
- register_shutdown_function('jd_fatal_error');
- //Register error handling function
- 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:
- //All test error types are captured using the following function
- 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 ''.$ type.':'.$message.' in '.$file.' on '.$line. ' line .
';
- }
-
- print_r(xx());
-
- // print_r(debug_backtrace());
- // print_r(debug_print_backtrace());
Copy code
|
Customize, php, register
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Articles by Author
-
2024-10-22 09:46:29
-
2024-10-13 13:53:41
-
2024-10-12 12:15:51
-
2024-10-11 22:47:31
-
2024-10-11 19:36:51
-
2024-10-11 15:50:41
-
2024-10-11 15:07:41
-
2024-10-11 14:21:21
-
2024-10-11 12:59:11
-
2024-10-11 12:17:31