PHP의 error_log () 함수
정의 및 사용
서버 오류 로그 파일 또는 원격 대상의 error_log () 함수는 오류를 보냅니다.
성공하면 실패 함수가 FALSE를 반환하는 경우, 함수는 TRUE를 반환합니다.
문법
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 오류 참조