함수 debug_print_backtrace
함수 debug_print_backtrace는 현재 실행 지점에 이르게 한 함수들의 순서인 현재 호출 스택에 대한 정보를 출력합니다. 이 함수는 값을 반환하지 않고 결과를 즉시 출력합니다. 첫 번째 매개변수로 출력 형식을 변경하기 위한 플래그를, 두 번째 매개변수로 출력할 레벨의 수를 제한할 수 있습니다.
구문
debug_print_backtrace(int $options = 0, int $limit = 0): void
예제
함수를 호출하는 간단한 예:
<?php
function a() {
b();
}
function b() {
debug_print_backtrace();
}
a();
?>
코드 실행 결과:
#0 b() called at [test.php:4]
#1 a() called at [test.php:8]
예제
출력을 제한하기 위한 limit 매개변수 사용:
<?php
function x() {
y();
}
function y() {
z();
}
function z() {
debug_print_backtrace(0, 2);
}
x();
?>
코드 실행 결과:
#0 z() called at [test.php:9]
#1 y() called at [test.php:6]
예제
출력 형식을 변경하기 위한 옵션 사용:
<?php
function test1() {
test2();
}
function test2() {
debug_print_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS);
}
test1();
?>
코드 실행 결과 (함수 인수 없이):
#0 test2() called at [test.php:4]
#1 test1() called at [test.php:8]
함께 보기
-
트레이스를 배열로 반환하는 함수
debug_backtrace,
-
오류 보고 수준을 설정하는 함수
error_reporting,