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:\wamp\www\meilele\includes\cls_mysql.php:471行,调用方法:query
D:\wamp\www\meilele\includes\cls_mysql.php:507行,调用方法:getAll
D:\wamp\www\meilele\includes\lib_common.php:732行,调用方法:getAllCached
D:\wamp\www\meilele\includes\init.php:113行,调用方法:load_config
D:\wamp\www\meilele\index.php:4行,调用方法:include_once