ThinkChat2.0新版上线,更智能更精彩,支持会话、画图、阅读、搜索等,送10W Token,即刻开启你的AI之旅 广告
## Exception异常对象转换为字符串显示 > 方法:exception_to_str(\Exception $e): string 参数: | 参数 | 类型 | 必须 | 说明 | | --- | --- | --- | --- | | `$e` | \Exception | 是 | 待转换的异常对象 | 返回值:string 类型 > 示例: ```php try{ throw new \Exception("测试异常"); }catch (\Exception $e){ var_dump(exception_to_str($e)); } ``` 输出结果: ``` Exception 测试异常 in C:\www\project_yunj_admin_universal_inster\yunj_admin_universal_interior\application\demo\controller\Index.php:14 Stack trace: #0 [internal function]: app\demo\controller\Index->welcome() #1 C:\www\project_yunj_admin_universal_inster\yunj_admin_universal_interior\thinkphp\library\think\Container.php(395): ReflectionMethod->invokeArgs(Object(app\demo\controller\Index), Array) #2 C:\www\project_yunj_admin_universal_inster\yunj_admin_universal_interior\thinkphp\library\think\route\dispatch\Module.php(131): think\Container->invokeReflectMethod(Object(app\demo\controller\Index), Object(ReflectionMethod), Array) #3 [internal function]: think\route\dispatch\Module->think\route\dispatch\{closure}(Object(think\Request), Object(Closure), NULL) #4 C:\www\project_yunj_admin_universal_inster\yunj_admin_universal_interior\thinkphp\library\think\Middleware.php(185): call_user_func_array(Object(Closure), Array) #5 [internal function]: think\Middleware->think\{closure}(Object(think\Request)) #6 C:\www\project_yunj_admin_universal_inster\yunj_admin_universal_interior\thinkphp\library\think\Middleware.php(130): call_user_func(Object(Closure), Object(think\Request)) #7 C:\www\project_yunj_admin_universal_inster\yunj_admin_universal_interior\thinkphp\library\think\route\dispatch\Module.php(136): think\Middleware->dispatch(Object(think\Request), 'controller') #8 C:\www\project_yunj_admin_universal_inster\yunj_admin_universal_interior\thinkphp\library\think\route\Dispatch.php(168): think\route\dispatch\Module->exec() #9 C:\www\project_yunj_admin_universal_inster\yunj_admin_universal_interior\thinkphp\library\think\App.php(432): think\route\Dispatch->run() #10 [internal function]: think\App->think\{closure}(Object(think\Request), Object(Closure), NULL) #11 C:\www\project_yunj_admin_universal_inster\yunj_admin_universal_interior\thinkphp\library\think\Middleware.php(185): call_user_func_array(Object(Closure), Array) #12 [internal function]: think\Middleware->think\{closure}(Object(think\Request)) #13 C:\www\project_yunj_admin_universal_inster\yunj_admin_universal_interior\thinkphp\library\think\Middleware.php(130): call_user_func(Object(Closure), Object(think\Request)) #14 C:\www\project_yunj_admin_universal_inster\yunj_admin_universal_interior\thinkphp\library\think\App.php(435): think\Middleware->dispatch(Object(think\Request)) #15 C:\www\project_yunj_admin_universal_inster\yunj_admin_universal_interior\public\index.php(21): think\App->run() #16 {main} ```