php Exception打印error trace 实例
对于php的Exception,可以通过getTraceAsString获得错误栈。
而对于error则应该如下:
function x()
$x = debug_backtrace();
//remove stack of this function
array_shift($x);
$i = 0;
$xstr = '';
foreach ($trace as $x) {
//TODO need check exists args
$args = $x['args'];
if (!$args) {
$argstr = '';
} else {
$argstr = '';
$first = true;
foreach ($args as $arg) {
if (!$first) {
$argstr .= ',';
}
$first = false;
if (is_object($arg)) {
$argstr .= 'Object[' . get_class($arg) . ']';
}
elseif (is_array($arg)) {
$argstr .= 'Array';
} else {
$argstr .= $arg;
}
}
}
$xstr .= "[#$i] {$x['file']}({$x['line']}) {$x['function']} ($argstr)" . PHP_EOL;
$i ;
}
return $xstr;
}
您可能感兴趣的文章:
php Exception打印error trace 实例
关于PHP中Exception、Error Handler的细节以及实例详解
php 异常处理try catch Exceptions
php的异常处理基础方法
CodeIgniter3.0 框架自定义异常处理的方法介绍
php soap客户端调试实例
php拦截异常怎么写
php调试利器:FirePHP的安装与使用
PHP 错误捕捉处理 Exception
PHP7.1和7.2 新增功能详解