如何让 PHP 在出错时产生回溯?

尝试使用默认的仅当前行错误消息来调试 PHP 是很可怕的.发生错误时,如何让 PHP 生成回溯(堆栈跟踪)?

Trying to debug PHP using its default current-line-only error messages is horrible. How can I get PHP to produce a backtrace (stack trace) when errors are produced?

推荐答案

Xdebug 打印关于错误的回溯表,并且您不必编写任何 PHP 代码来实现它.

Xdebug prints a backtrace table on errors, and you don't have to write any PHP code to implement it.

缺点是您必须将其安装为 PHP 扩展.

Downside is you have to install it as a PHP extension.

相关文章