PHP error_log() 함수
예시
웹 서버의 오류 로그와 메일 계정에 오류 메시지를 보냅니다.
<?php
// Send error message to the server log if error connecting to the database
if (!mysqli_connect("localhost","bad_user","bad_password","my_db")) {
error_log("Failed to connect to database!", 0);
}
// Send email to administrator if we run out of FOO
if (!($foo = allocate_new_foo())) {
error_log("Oh no! We are out of FOOs!", 1, "[email protected]");
}
?>
정의 및 사용
error_log() 함수는 오류 메시지를 로그, 파일 또는 메일 계정으로 보냅니다.
통사론
error_log(message, type, destination, headers);
매개변수 값
Parameter | Description |
---|---|
message | Required. Specifies the error message to log |
type | Optional. Specifies where the error message should go.
Possible values:
|
destination | Optional. Specifies the destination of the error message. This value depends on the value of the type parameter |
headers | Optional. Only used if the type parameter is set to 1. Specifies additional headers, like From, Cc, and Bcc. Multiple headers should be separated with a CRLF (\r\n) |
기술적 세부 사항
반환 값: | 성공 시 TRUE입니다. 실패시 FALSE |
---|---|
PHP 버전: | 4.0+ |
바이너리 금고: | 아니 |
PHP 변경 로그: | PHP 5.2.7: 4 값이 유형 매개변수 에 추가되었습니다. |
PHP 오류 참조