是否可以让 PHP 错误看起来更好一些?堆栈跟踪可以在单独的行上输出吗?
现在 PHP 只是在页面上转储如下内容:
致命错误:无法重新声明 Cms\getItemHierarchy()(以前 声明于 /home/cartman/Development/cmsdev/engine_1.0/Cms/Menu.php:62) 在 /home/cartman/Development/cmsdev/engine_1.0/Cms/Menu.php 第 62 行 调用堆栈:0,0001 634424 1. {main}() /home/cartman/Development/cmsdev/public_normal/index.php:0 0,0037 757768 2.Bootstrap::run() /home/cartman/Development/cmsdev/public_normal/index.php:7 0,0037 757768 3. Cms\Front->dispatch() /home/cartman/Development/cmsdev/data_product/bootstrap.php:94 0,0043 781512 4. frontendController->contactusAction() /home/cartman/开发/cmsdev/engine_1.0/Cms/Front.php:367 0,0051 817152 5.plugins\m3nu\api->renderMenu($configName = 'bottom', $activeItem = '联系我') /home/cartman/Development/cmsdev/data_product/controllers/frontendController.php:43 0,0052 825392 6. Cms\Menu->generateMenu() /home/cartman/Development/cmsdev/public_normal/plugins/m3nu/api.php:29 0,0052 825392 7. Cms\Menu->preParseConfig() /home/cartman/Development/cmsdev/engine_1.0/Cms/Menu.php:121
有没有办法使输出看起来更有组织性,至少在单独的行上打印堆栈跟踪?
Right now PHP simply dumps something like this on the page:
Fatal error: Cannot redeclare Cms\getItemHierarchy() (previously
declared in
/home/cartman/Development/cmsdev/engine_1.0/Cms/Menu.php:62) in
/home/cartman/Development/cmsdev/engine_1.0/Cms/Menu.php on line 62
Call Stack: 0,0001 634424 1. {main}()
/home/cartman/Development/cmsdev/public_normal/index.php:0 0,0037
757768 2. Bootstrap::run()
/home/cartman/Development/cmsdev/public_normal/index.php:7 0,0037
757768 3. Cms\Front->dispatch()
/home/cartman/Development/cmsdev/data_production/bootstrap.php:94
0,0043 781512 4. frontendController->contactusAction()
/home/cartman/Development/cmsdev/engine_1.0/Cms/Front.php:367 0,0051
817152 5. plugins\m3nu\api->renderMenu($configName = 'bottom',
$activeItem = 'contactme')
/home/cartman/Development/cmsdev/data_production/controllers/frontendController.php:43
0,0052 825392 6. Cms\Menu->generateMenu()
/home/cartman/Development/cmsdev/public_normal/plugins/m3nu/api.php:29
0,0052 825392 7. Cms\Menu->preParseConfig()
/home/cartman/Development/cmsdev/engine_1.0/Cms/Menu.php:121
Is there a way to make the output look more organized, at least print stack trace on separate lines?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
您还可以更新 php.ini 以包含一些 HTML 格式。
或者,如果您希望在运行时设置它们,请在脚本顶部包含以下内容
You can also update the php.ini to include some formatting HTML.
Or if you'd prefer to set them at runtime include the following at the top of your script(s)
这似乎是 XDebug 堆栈跟踪。尝试在
php.ini
中设置 trace_format:This seems to be an XDebug stack trace. Try setting trace_format in
php.ini
:如果您从浏览器中查看它们,则可以将其包装在
标记中,这实际上会将换行符显示为换行符。
否则,如果您在 DOM 之外查看,即在控制台或源查看器中,您会发现它们已经“很好”地格式化了
If you are viewing them from a browser, you can wrap it in
<pre></pre>
tags which will essentially present your newline characters as line breaks.
Otherwise, if you are viewing outside of DOM, i.e., in console or source viewer, you will find they are already formatted "nicely"