debug_backtrace

说明:

产生一条回溯跟踪

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

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

Hi:friend
C:softwwwceshi1.php:5:
array (size=3)
  0 => 
    array (size=4)
      'file' => string 'C:softwwwceshi1.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:softwwwceshi2.php' (length=23)
      'line' => int 2
      'args' => 
        array (size=1)
          0 => string 'C:softwwwceshi1.php' (length=23)
      'function' => string 'include_once' (length=12)
  2 => 
    array (size=4)
      'file' => string 'C:softwwwceshi3.php' (length=23)
      'line' => int 2
      'args' => 
        array (size=1)
          0 => string 'C:softwwwceshi2.php' (length=23)
      'function' => string 'include_once' (length=12)