error_log
(PHP3 , PHP4)
error_log --- 送出錯誤訊息到某處
語法 :
int error_log(string message, int message_type [, string destination [, string extra_headers]])說明 :
送出一個錯誤訊息到web伺服器的錯誤記錄,一個TCP埠號或是一個檔案。第一個參數message是將要被記錄的一個錯誤訊息內容,第二個參數message_type說明訊息要送往何處 :
error_log( )記錄的型態 :
0 message送到PHP的系統記錄者,使用作業系統的系統記錄機制或是檔案,取決於error_log的設定值。 1 以email的方式將message送到參數destination指定的地址,只有這個型態才會使用到extra_headers,此型態使用相同的內部函式mail( )。 2 message送到PHP除錯連結,只有在遠端的除錯設為enable時,這個選項才有效。參數destination用來指定接收除錯訊息的主機名稱或是IP位址,埠號。 3 message附加在檔案destination。 Example :
<?php
// Send notification through the server log if we can not
// connect to the database.
if (!Ora_Logon($username, $password)) {
error_log("Oracle database not available!", 0);
}
// Notify administrator by email if we run out of FOOif (!($foo = allocate_new_foo()) {
error_log ("Big trouble, we're all out of FOOs!", 1, "operator@mydomain.com");
}
// other ways of calling error_log():error_log ("You messed up!", 2, "127.0.0.1:7000");
error_log ("You messed up!", 2, "loghost");
error_log ("You messed up!", 3, "/var/tmp/my-errors.log");
?>