Hàm debug_backtrace() trong PHP
Ví dụ
Tạo một vết ngược PHP:
<?php
function a($txt) {
b("Glenn");
}
function b($txt) {
c("Cleveland");
}
function c($txt) {
var_dump(debug_backtrace());
}
a("Peter");
?>
Hãy tự mình thử »Định nghĩa và cách sử dụng
Hàm debug_backtrace() tạo ra vết ngược 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ể được 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ả về: | Một mảng các mảng kết hợp |
---|---|
Phiên bản PHP: | 4.3+ |
Nhật ký thay đổi PHP: | PHP 5.4: Đã thêm giới hạn tham số tùy chọn PHP 5.3.6: Tham số Provide_object đã đượ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 Provide_object đã được thêm vào PHP 5.1.1: Đã thêm đối tượng hiện tại làm phần tử trả về có thể |
Tham chiếu lỗi PHP