PHP error_log() 函數(shù)
定義和用法
error_log() 函數(shù)向服務(wù)器錯誤記錄、文件或遠(yuǎn)程目標(biāo)發(fā)送一個錯誤。
若成功,返回 true,否則返回 false。
語法
error_log(error,type,destination,headers)
參數(shù) | 描述 |
---|---|
error | 必需。要記錄的錯誤消息。 |
type |
可選。規(guī)定錯誤記錄的類型。 可能的記錄類型:
|
destination | 可選。規(guī)定向何處發(fā)送錯誤消息。該參數(shù)的值依賴于 "type" 參數(shù)的值。 |
headers |
可選。只在 "type" 為 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"); } ?>
輸出:
A custom error has been triggered