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) |
รายละเอียดทางเทคนิค
คืนมูลค่า: | จริงกับความสำเร็จ FALSE เมื่อล้มเหลว |
---|---|
รุ่น PHP: | 4.0+ |
ตู้เซฟไบนารี: | ไม่ |
บันทึกการเปลี่ยนแปลง PHP: | PHP 5.2.7: เพิ่มค่า 4 ให้กับประเภทพารามิเตอร์ |
การอ้างอิงข้อผิดพลาด PHP