Computer >> บทช่วยสอนคอมพิวเตอร์ >  >> การเขียนโปรแกรม >> PHP

ฟังก์ชัน debug_print_backtrace() ใน PHP

คำอธิบาย

ฟังก์ชัน debug_print_backtrace() แสดงการติดตามย้อนกลับ (backtrace) ของการเรียกฟังก์ชัน ไม่คืนค่าอะไร

รูปแบบการใช้งาน (Syntax)

debug_print_backtrace(options, limit)

พารามิเตอร์

  • options — บิตมาสก์สำหรับตัวเลือก:
    • DEBUG_BACKTRACE_IGNORE_ARGS — ไม่รวมดัชนี "args" และอาร์กิวเมนต์ของฟังก์ชัน เพื่อประหยัดหน่วยความจำ
  • limit — จำกัดจำนวนเฟรมสแต็กที่แสดง

ค่าที่คืนกลับ

ไม่คืนค่า (void)

ตัวอย่างการใช้งาน

<?php
function Test1() {
    Test2();
}
function Test2() {
    Test3();
}
function Test3() {
    Test4();
}
function Test4() {
    debug_print_backtrace();
}
Test1();
?>

ผลลัพธ์

#0  Test4() called at [/path/to/script.php:10]
#1  Test3() called at [/path/to/script.php:8]
#2  Test2() called at [/path/to/script.php:6]
#3  Test1() called at [/path/to/script.php:12]