PHP의 debug_backtrace () 함수
정의 및 사용
debug_backtrace () 함수는 역 추적을 생성합니다.
이 기능은 debug_backtrace () 함수 코드 생성 데이터가 표시됩니다.
그것은 연관 배열을 반환합니다. 여기에 반환 될 수있는 요소는 다음과 같습니다
名称 | 类型 | 描述 |
---|---|---|
function | string | 当前的函数名。 |
line | integer | 当前的行号。 |
file | string | 当前的文件名。 |
class | string | 当前的类名。 |
object | object | 当前对象。 |
type | string | 当前的调用类型,可能的调用:
|
args | array | 如果在函数中,列出函数参数。如果在被引用的文件中,列出被引用的文件名。 |
문법
debug_backtrace()
예
<?php
function one($str1, $str2)
{
two("Glenn", "Quagmire");
}
function two($str1, $str2)
{
three("Cleveland", "Brown");
}
function three($str1, $str2)
{
print_r(debug_backtrace());
}
one("Peter", "Griffin");
?>
function one($str1, $str2)
{
two("Glenn", "Quagmire");
}
function two($str1, $str2)
{
three("Cleveland", "Brown");
}
function three($str1, $str2)
{
print_r(debug_backtrace());
}
one("Peter", "Griffin");
?>
다음 위 코드의 출력은 :
Array
(
[0] => Array
(
[file] => C:webfoldertest.php
[line] => 7
[function] => three
[args] => Array
(
[0] => Cleveland
[1] => Brown
)
)
[1] => Array
(
[file] => C:webfoldertest.php
[line] => 3
[function] => two
[args] => Array
(
[0] => Glenn
[1] => Quagmire
)
)
[2] => Array
(
[file] => C:webfoldertest.php
[line] => 14
[function] => one
[args] => Array
(
[0] => Peter
[1] => Griffin
)
)
)
(
[0] => Array
(
[file] => C:webfoldertest.php
[line] => 7
[function] => three
[args] => Array
(
[0] => Cleveland
[1] => Brown
)
)
[1] => Array
(
[file] => C:webfoldertest.php
[line] => 3
[function] => two
[args] => Array
(
[0] => Glenn
[1] => Quagmire
)
)
[2] => Array
(
[file] => C:webfoldertest.php
[line] => 14
[function] => one
[args] => Array
(
[0] => Peter
[1] => Griffin
)
)
)
전체 PHP 오류 참조