Hàm debug_backtrace () trong PHP
Thí dụ
Tạo backtrace PHP:
<?php
function a($txt) {
b("Glenn");
}
function b($txt) {
c("Cleveland");
}
function c($txt) {
var_dump(debug_backtrace());
}
a("Peter");
?>
Định nghĩa và Cách sử dụng
Hàm debug_backtrace () tạo ra một backtrace PHP.
Hàm này hiển thị dữ liệu từ mã dẫn đến hàm debug_backtrace ().
Trả về một mảng các mảng kết hợp. Các phần tử có thể trả về là:
Name | Type | Description |
---|---|---|
function | string | The current function name |
line | integer | The current line number |
file | string | The current file name |
class | string | The current class name |
object | object | The current object |
type | string | The current call type. Possible calls:
|
args | array | If inside a function, it lists the functions arguments. If inside an included file, it lists the included file names |
Cú pháp
debug_backtrace(options, limit);
Giá trị tham số
Parameter | Description |
---|---|
options | Optional. Specifies a bitmask for the following options: DEBUG_BACKTRACE_PROVIDE_OBJECT (Whether or not to populate the "object" index DEBUG_BACKTRACE_IGNORE_ARGS (Whether or not to omit the "args" index, and all the function/method arguments, to save memory) |
limit | Optional. Limits the number of stack frames printed. By default (limit=0) it prints all stack frames |
Chi tiết kỹ thuật
Giá trị trả lại: | Một mảng các mảng kết hợp |
---|---|
Phiên bản PHP: | 4.3+ |
PHP Changelog: | PHP 5.4: Giới hạn tham số tùy chọn đã được thêm vào PHP 5.3.6: Tham số cung cấp đã được thay đổi thành tùy chọn và tùy chọn bổ sung DEBUG_BACKTRACE_IGNORE_ARGS được thêm vào PHP 5.2.5: Tham số tùy chọn cung cấp đã được thêm vào PHP 5.1.1: Đã thêm đối tượng hiện tại càng tốt phần tử trả lại |
Tham chiếu lỗi PHP