function print_stack_trace() { $array =debug_backtrace(); //print_r($array);//信息很齐全 unset($array[0]); foreach($array as $row) { $html .=$row['file'].':'.$row['line'].'行,调用方法:'.$row['function']."<p>"; } return$html; }
我在我的数据库的核心查询函数里面调用这个方法,打印结果如下:
D:wampwwwmeileleincludescls_mysql.php:471行,调用方法:query
D:wampwwwmeileleincludescls_mysql.php:507行,调用方法:getAll
D:wampwwwmeileleincludeslib_common.php:732行,调用方法:getAllCached
D:wampwwwmeileleincludesinit.php:113行,调用方法:load_config
D:wampwwwmeileleindex.php:4行,调用方法:include_once