error_log
送出一個錯誤信息。
語法: int error_log(string message, int message_type, string [destination], string [extra_headers]);
返回值: 整數
函數種類: PHP 繫統功能
此函數會送出錯誤信息到 Web 服務器的錯誤 log 文件,TCP Port,或到指定文件。第一個參數 message 即為要送出的錯誤信息。第二個參數 message_type 為整數值:0 表示送到操作繫統的 log (UNIX 在 syslog、Windows NT 記錄到事件記錄);1 則使用 PHP 的 Mail() 函數,送信息到某 E-Mail 處,第四個參數 extra_headers 亦會用到;2 則將錯誤信息送到 TCP 埠,此時第三個參數 destination 表示目的地 IP 及 Port;3 則將信息存到文件 destination 中。
本例為登入 Oracle 數據庫出現問題的處理。
<?php if (!Ora_Logon($username, $password)) { error_log("Oracle 數據庫不可用!", 0); } if (!($foo = allocate_new_foo()) { error_log("出現大麻煩了!", 1, "webmaster@www.mydomain.com.tw"); } error_log("搞砸了!", 2, "127.0.0.1:7000"); error_log("搞砸了!", 2, "loghost"); error_log("搞砸了!", 3, "/var/tmp/my-errors.log"); ?>
整理: 夕垌菪姬 (天地JPLOP)
|