debug_backtrace

PHP回溯跟踪解析
本文通过一个具体的PHP代码示例,详细解释了如何使用debug_backtrace()函数来生成和解析回溯跟踪,帮助开发者理解代码的调用层级和流程。

说明:

产生一条回溯跟踪

//1.php
function test($str)
{
    echo '\nHi:'.$str;
    var_dump(debug_backtrace());
}
test('friend');
//2.php
include_once './1.php';
include_once './2.php';

打印结果:最内部文件是第一个数组,最外部文件是最后一个数组

\nHi:friend
C:\soft\www\ceshi\1.php:5:
array (size=3)
  0 => 
    array (size=4)
      'file' => string 'C:\soft\www\ceshi\1.php' (length=23)
      'line' => int 7
      'function' => string 'test' (length=4)
      'args' => 
        array (size=1)
          0 => string 'friend' (length=6)
  1 => 
    array (size=4)
      'file' => string 'C:\soft\www\ceshi\2.php' (length=23)
      'line' => int 2
      'args' => 
        array (size=1)
          0 => string 'C:\soft\www\ceshi\1.php' (length=23)
      'function' => string 'include_once' (length=12)
  2 => 
    array (size=4)
      'file' => string 'C:\soft\www\ceshi\3.php' (length=23)
      'line' => int 2
      'args' => 
        array (size=1)
          0 => string 'C:\soft\www\ceshi\2.php' (length=23)
      'function' => string 'include_once' (length=12)

 

转载于:https://www.cnblogs.com/zxqblogrecord/p/10528729.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值