2011-09-22

CODE - php 使用 backtrace bug

紀錄一下...

要做 backtrace 時, 通常可以在 error_log 裡加上 SERVER['PHP_SELF']
來看是誰呼叫 func or module 的

但在 zendframe work 下就無法這樣用, 要用 getenv("REQUEST_URI")

或者直接使用 php 內建的 debug_backtrace()
$raw = debug_backtrace();
foreach($raw as $entry) {
    $output.="\nFile: ".$entry['file']." (Line: ".$entry['line'].")\n";
    $output.="Function: ".$entry['function']."\n";
    $output.="Args: ".implode(", ", $entry['args'])."\n";
    error_log($output);
}
cf : http://tw.php.net/manual/en/function.debug-backtrace.php


沒有留言:

張貼留言