企业🤖AI Agent构建引擎,智能编排和调试,一键部署,支持私有化部署方案 广告
:-: 异常处理-Error 类 ~~~ /** * 注册异常处理 * @access public * @return void */ public static function register() { error_reporting(E_ALL); set_error_handler([__CLASS__, 'appError']); set_exception_handler([__CLASS__, 'appException']); register_shutdown_function([__CLASS__, 'appShutdown']); } ~~~ ` error_reporting(E_ALL); ` // 报告所有错误 [`set_error_handler `](http://php.net/manual/zh/function.set-error-handler.php)— 设置用户自定义的错误处理函数 ;重要的是要记住 error_types 里指定的错误类型都会绕过 PHP 标准错误处理程序, 除非回调函数返回了 FALSE [`set_exception_handler`](http://php.net/manual/zh/function.set-exception-handler.php) — 设置用户自定义的异常处理函 数 ; 设置默认的异常处理程序,用于没有用 try/catch 块来捕获的异常。 在 exception_handler 调用后异常会中止。 [register_shutdown_function](http://php.net/manual/zh/function.register-shutdown-function.php) — 注册一个会在php中止时执行的函数 ;注册一个 callback ,它会在脚本执行完成或者 exit() 后被调用。 可以多次调用 register_shutdown_function() ,这些被注册的回调会按照他们注册时的顺序被依次调用。 如果你在注册的方法内部调用 exit(), 那么所有处理会被中止,并且其他注册的中止回调也不会再被调用。 `__CLASS__`:获取当前的类名, `get_class()`与上面一样,都是获取当前的类名 `get_called_class()`获取当前主调类的类名