error_log

(PHP 4, PHP 5, PHP 7, PHP 8)

error_log - 정의된 오류 처리 루틴에 오류 메시지를 보냅니다.


설명

error_log(
    string $message,
    int $message_type = 0,
    string $destination = ?,
    string $extra_headers = ?
): bool
                

웹 서버의 오류 로그 또는 파일에 오류 메시지를 보냅니다.


매개변수

message
기록해야 하는 오류 메시지입니다.
message_type
오류가 어디로 가야 하는지 알려줍니다. 가능한 메시지 유형은 다음과 같습니다.

error_log() 로그 유형

0 messageerror_log 구성 지시문이 무엇으로 설정되었는지에 따라 운영 체제의 시스템 로깅 메커니즘 또는 파일을 사용하여 PHP의 시스템 로거로 전송됩니다. 이것은 기본 옵션입니다.
1 messagedestination 매개변수의 주소로 이메일로 전송됩니다. 이것은 네 번째 매개변수 extra_headers가 사용되는 유일한 메시지 유형입니다.
2 더 이상 옵션이 아닙니다.
3 message가 파일 destination에 추가됩니다. 줄 바꿈은 message 문자열 끝에 자동으로 추가되지 않습니다.
4 message는 SAPI 로깅 핸들러로 직접 전송됩니다.
destination
목적지. 그 의미는 위에서 설명한 대로 message_type 매개변수에 따라 다릅니다.
extra_headers
추가 헤더. message_type 매개변수가 1로 설정된 경우에 사용됩니다. 이 메시지 유형은 mail()과 동일한 내부 함수를 사용합니다.

반환 값

성공하면 true를, 실패하면 false를 반환합니다. message_type이 0이면 이 함수는 오류를 기록할 수 있는지 여부에 관계없이 항상 true를 반환합니다.


Examples

예제 #1 error_log() 예제

                  
<?php
// Send notification through the server log if we can not
// connect to the database.
if (!Ora_Logon($username, $password)) {
    error_log("Oracle database not available!", 0);
}

// Notify administrator by email if we run out of FOO
if (!($foo = allocate_new_foo())) {
    error_log("Big trouble, we're all out of FOOs!", 1,
               "operator@example.com");
}

// another way to call error_log():
error_log("You messed up!", 3, "/var/tmp/my-errors.log");
?>
                  
                

노트

경고 error_log()는 바이너리 안전하지 않습니다. message는 null 문자로 잘립니다.

message에는 null 문자가 포함되어서는 안 됩니다. message는 파일, 메일, syslog 등으로 전송될 수 있습니다. error_log()를 호출하기 전에 적절한 변환/이스케이프 함수, base64_encode(), rawurlencode() 또는 addlashes()를 사용하십시오.