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)

 

posted on 2019-03-14 10:43  running-fly  阅读(164)  评论(0编辑  收藏  举报

导航