PHP error_log() 函數
定義和用法
error_log() 函數向服務器錯誤記錄、文件或遠程目標發送一個錯誤。
如果成功該函數返回TRUE,如果失敗該函數返回FALSE。
語法
error_log(error,type,destination,headers)
参数 | 描述 |
---|---|
error | 必需。要记录的错误消息。 |
type | 可选。规定错误记录的类型。 可能的记录类型:
|
destination | 可选。规定向何处发送错误消息。该参数的值依赖于 "type" 参数的值。 |
headers | 可选。只在 "type" 参数为 1 时使用。规定附加的头部,比如 From, Cc 以及 Bcc。附加头部由 CRLF (\r\n) 分隔。
注意:在发送电子邮件时,必须包含 From 头部。可以在 php.ini 文件中或者通过此参数设置。 |
實例
下面的實例發送一封帶有自定義錯誤的電子郵件:
<?php
$test=2;
if ($test>1)
{
error_log("A custom error has been triggered",
1,"[email protected]","From: [email protected]");
}
?>
$test=2;
if ($test>1)
{
error_log("A custom error has been triggered",
1,"[email protected]","From: [email protected]");
}
?>
上面代碼接收到的郵件如下所示:
A custom error has been triggered
完整的PHP Error參考手冊