是否有php.ini指令启用对错误的堆栈跟踪? [英] Is there a php.ini directive that enables stack traces on errors?

查看:72
本文介绍了是否有php.ini指令启用对错误的堆栈跟踪?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否存在一个php.ini指令,该指令可以对错误进行堆栈跟踪?我已经看过这里了: http://php.net/manual/en/ini.core .php .由于某些原因,我的共享主机未安装Xdebug.我尝试将它们放在.htaccess中:

Is there a php.ini directive that enables stack traces on errors? I already looked here: http://php.net/manual/en/ini.core.php. My shared-hosting does not have Xdebug installed for some reason. I tried putting these in .htaccess:

php_value track_erors On
php_value report_zend_debug 1

但没有堆栈跟踪.

推荐答案

debug_backtrace .但是,这对于致命错误将不起作用,因为这些错误无法处理.

There's debug_backtrace. This won't work for fatal errors though, since those cannot be handled.

示例:

<?php
function exceptions_error_handler($severity, $message, $filename, $lineno) { 
    var_dump(debug_backtrace());
}

set_error_handler('exceptions_error_handler');

function c() {
echo $a;
}

c();

给予:


array
  0 => 
    array
      'file' => string '/tmp/cpu7HL5A' (length=13)
      'line' => int 9
      'function' => string 'exceptions_error_handler' (length=24)
      'args' => 
        array
          0 => &int 8
          1 => &string 'Undefined variable: a' (length=21)
          2 => &string '/tmp/cpu7HL5A' (length=13)
          3 => &int 9
          4 => &
            array
              empty
  1 => 
    array
      'file' => string '/tmp/cpu7HL5A' (length=13)
      'line' => int 12
      'function' => string 'c' (length=1)
      'args' => 
        array
          empty

这篇关于是否有php.ini指令启用对错误的堆栈跟踪?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆