PHP堆栈调试操作简单示例 本文实例讲述了PHP堆栈调试操作。分享给大家供大家参考,具体如下: 你是否想知道当前函数被哪些文件调用了,如果知道了这些路径,我们就能很好的理解程序的执行过程,这是非常重要的,也是了解别人程序的基础,那么这里我就给大家介绍一种php中的堆栈调试的方法,其实就是php内置的一个函数debug_backtrace(); 下面是就稍微介绍一下吧,具体还是要看手册哦,喜欢看手册的程序员才是前途无量的 $statcks = debug_backtrace(); $tmp_arr = array(); if(!$stacks) return $tmp_arr; foreach($stacks as $k=>$v) { $tmp[$k]['file'] = isset($v['file']) ? $v['file'] : '--'; $tmp[$k]['line'] = isset($v['line'])? $v['line'] : '--'; $tmp[$k]['function'] = isset($v['function']) ? $v['function'] : '--'; } 运行结果: Array ( [0] => Array ( [file] => D:\wwwroot\CodeIgniter\application\controllers\finance\channel.php [line] => 128 [function] => get_total_rows ) [1] => Array ( [file] => -- [line] => -- [function] => index ) [2] => Array ( [file] => D:\wwwroot\CodeIgniter\application\controllers\finance\channel.php [line] => 46 [function] => call_user_func ) [3] => Array ( [file] => -- [line] => -- [function] => get_nav ) [4] => Array ( [file] => D:\wwwroot\CodeIgniter\system\core\CodeIgniter.php [line] => 360 [function] => call_user_func_array ) [5] => Array ( [file] => D:\wwwroot\CodeIgniter\index.php [line] => 205 [function] => require_once ) ) 这里是打印出来的数组,非常的好了 更多关于PHP相关内容感兴趣的读者可查看本站专题:《PHP错误与异常处理方法总结》、《php字符串(string)用法总结》、《PHP数组(Array)操作技巧大全》、《PHP运算与运算符用法总结》、《PHP网络编程技巧总结》、《PHP基本语法入门教程》、《php面向对象程序设计入门教程》、《php+mysql数据库操作入门教程》及《php常见数据库操作技巧汇总》 希望本文所述对大家PHP程序设计有所帮助。