PHP error_log() Fungsi
Contoh
Kirim pesan kesalahan ke log kesalahan server web dan ke akun email:
<?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]");
}
?>
Definisi dan Penggunaan
Fungsi error_log() mengirimkan pesan kesalahan ke log, ke file, atau ke akun email.
Sintaksis
error_log(message, type, destination, headers);
Nilai Parameter
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) |
Detail Teknis
Nilai Kembali: | BENAR pada kesuksesan. SALAH pada kegagalan |
---|---|
Versi PHP: | 4.0+ |
Biner Aman: | Tidak |
Log Perubahan PHP: | PHP 5.2.7: Nilai 4 ditambahkan ke parameter tipe |
Referensi Kesalahan PHP