原文:http://www.dabing.me/?p=341
//堆栈调试用来查找调用函数的源头
function query($sql, $type = '')
{
function print_stack_trace()
{
$array = debug_backtrace();
//print_r($array);//信息很齐全
unset($array[0]);
foreach($array as $row)
{
$html .= $row['file'].':<font color="#FF0000">'.$row['line'].' line</font>,
FUNCTION:<font color="#FF0000">'.$row['function']."</font><p>";
}
echo $html;
}
print_stack_trace();
}
//打印结果:
//D:\wamp\www\dz7.2_uchome_uc\bbs\include\common.inc.php:208 line,FUNCTION:query
//D:\wamp\www\dz7.2_uchome_uc\bbs\index.php:12 line,FUNCTION:require_once