2023年 3月 31日
歡迎 ! 新來賓
[ 登入 ]
主頁 | 客戶中心 | 技術支援中心
訂閱 RSS | 設為首頁 | 加入最愛
資料搜尋:
瀏覽:

「PHP」如何建立自已的PHP除錯日誌文件

建立日期: 2009年 4月 1日   (14 年前) 閱讀次數: 2034 評價: 

概覽

請在您的PHP加入以下程式。(或者建立一個獨立檔案,利用「include()」把程式包含)

   error_reporting(0);
$old_error_handler = set_error_handler("userErrorHandler");
function userErrorHandler ($errno, $errmsg, $filename, $linenum, $vars)
{
$time=date("d M Y H:i:s");
// Get the error type from the error number
$errortype = array (1 => "Error",
2 => "Warning",
4 => "Parsing Error",
8 => "Notice",
16 => "Core Error",
32 => "Core Warning",
64 => "Compile Error",
128 => "Compile Warning",
256 => "User Error",
512 => "User Warning",
1024 => "User Notice");
$errlevel=$errortype[$errno];
//Write error to log file (CSV format)
$errfile=fopen("errors.csv","a");
fputs($errfile,"\"$time\",\"$filename:
$linenum\",\"($errlevel) $errmsg\"\r\n");
fclose($errfile);

if($errno!=2 && $errno!=8) {
//Terminate script if fatal error
die("A fatal error has occurred. Script execution has been aborted");
}
}
*** 以上提供的資料僅供參考,如有需要,請諮詢獨立技術顧問的意見。
這文章對您有幫助嗎?
您可以加進最愛的書籤:DiggredditDeliciousGoogle BookmarksWindows LiveFacebookSlashdot BookmarksPropellerTechnoratiBlinkListYahoo bookmarksMa.gnoliaSquidoo
靜態連結:  
 
ec2Biz.com 互動多媒體、網頁寄存、網上商店、域名註冊、電子商貿方案 | Ecommerce Web Hosting Solutions
©2023 Focus Network Company. 版權所有 不得轉載