PHP error_log() 函數(shù)

定義和用法
error_log() 函數(shù)向服務(wù)器錯誤記錄、文件或遠(yuǎn)程目標(biāo)發(fā)送一個錯誤。
如果成功該函數(shù)返回 TRUE,如果失敗該函數(shù)返回 FALSE。
語法
error_log(error,type,destination,headers)
參數(shù) | 描述 |
---|---|
error | 必需。要記錄的錯誤消息。 |
type | 可選。規(guī)定錯誤記錄的類型。 可能的記錄類型:
|
destination | 可選。規(guī)定向何處發(fā)送錯誤消息。該參數(shù)的值依賴于 "type" 參數(shù)的值。 |
headers | 可選。只在 "type" 參數(shù)為 1 時使用。規(guī)定附加的頭部,比如 From, Cc 以及 Bcc。附加頭部由 CRLF (\r\n) 分隔。 注意:在發(fā)送電子郵件時,必須包含 From 頭部??梢栽?php.ini 文件中或者通過此參數(shù)設(shè)置。 |
實例
下面的實例發(fā)送一封帶有自定義錯誤的電子郵件:
<?php
$test=2;
if ($test>1)
{
error_log("A custom error has been triggered",
1,"someone@example.com","From: webmaster@example.com");
}
?>
$test=2;
if ($test>1)
{
error_log("A custom error has been triggered",
1,"someone@example.com","From: webmaster@example.com");
}
?>
上面代碼接收到的郵件如下所示:
A custom error has been triggered

更多建議: