บทช่วยสอนPHP

PHP HOME แนะนำ PHP การติดตั้ง PHP PHP ไวยากรณ์ ความคิดเห็น PHP ตัวแปร PHP PHP Echo / พิมพ์ ประเภทข้อมูล PHP PHP Strings หมายเลข PHP PHP คณิตศาสตร์ ค่าคงที่ PHP ตัวดำเนินการ PHP PHP If...Else...Elseif PHP Switch PHP Loops ฟังก์ชัน PHP PHP Arrays PHP Superglobals PHP RegEx

แบบฟอร์มPHP

การจัดการแบบฟอร์ม PHP การตรวจสอบแบบฟอร์ม PHP ต้องใช้แบบฟอร์ม PHP URL แบบฟอร์ม PHP/อีเมล แบบฟอร์ม PHP เสร็จสมบูรณ์

PHPขั้นสูง

วันที่และเวลา PHP รวม PHP การจัดการไฟล์ PHP ไฟล์ PHP เปิด/อ่าน สร้าง/เขียนไฟล์ PHP อัพโหลดไฟล์ PHP คุกกี้ PHP PHP Sessions ตัวกรอง PHP ตัวกรอง PHP ขั้นสูง ฟังก์ชันเรียกกลับของ PHP PHP JSON ข้อยกเว้น PHP

PHP OOP

PHP OOP คืออะไร คลาส PHP/วัตถุ ตัวสร้าง PHP PHP Destructor PHP Access Modifiers PHP Inheritance ค่าคงที่ PHP PHP Abstract Classes อินเทอร์เฟซ PHP PHP ลักษณะ PHP Static Methods PHP คุณสมบัติคงที่ PHP เนมสเปซ PHP Iterables

ฐานข้อมูลMySQL

ฐานข้อมูล MySQL MySQL Connect MySQL สร้าง DB MySQL สร้างตาราง MySQL แทรกข้อมูล MySQL รับ ID ล่าสุด MySQL แทรกหลายรายการ MySQL ที่เตรียมไว้ MySQL Select Data MySQL Where MySQL สั่งซื้อโดย MySQL ลบข้อมูล ข้อมูลอัพเดต MySQL MySQL Limit Data

PHP XML

PHP XML Parsers PHP SimpleXML Parser PHP SimpleXML - รับ PHP XML Expat PHP XML DOM

PHP - AJAX

บทนำ AJAX AJAX PHP ฐานข้อมูล AJAX AJAX XML AJAX ค้นหาสด AJAX โพล

ตัวอย่างPHP

ตัวอย่าง PHP PHP คอมไพเลอร์ แบบทดสอบ PHP แบบฝึกหัด PHP ใบรับรอง PHP

ข้อมูลอ้างอิงPHP

ภาพรวม PHP PHP Array ปฏิทิน PHP PHP วันที่ ไดเรกทอรี PHP ข้อผิดพลาด PHP ข้อยกเว้น PHP ระบบไฟล์ PHP ตัวกรอง PHP PHP FTP PHP JSON คีย์เวิร์ด PHP PHP Libxml PHP Mail PHP คณิตศาสตร์ PHP เบ็ดเตล็ด PHP MySQLi เครือข่าย PHP การควบคุมเอาต์พุต PHP PHP RegEx PHP SimpleXML PHP Stream PHP String การจัดการตัวแปร PHP PHP XML Parser PHP Zip เขตเวลา PHP

PHP error_log()ฟังก์ชั่น

การอ้างอิงข้อผิดพลาด PHP

ตัวอย่าง

ส่งข้อความแสดงข้อผิดพลาดไปยังบันทึกข้อผิดพลาดของเว็บเซิร์ฟเวอร์และไปยังบัญชีเมล:

<?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:
  • 0 - Default. Message is sent to PHP's system logger, using the OS' system logging mechanism or a file, depending on what the error_log configuration is set to in php.ini
  • 1 - Message is sent by email to the address in the destination parameter
  • 2 - No longer in use (only available in PHP 3)
  • 3 - Message is appended to the file specified in destination
  • 4 - Message is sent directly to the SAPI logging handler
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