Functie xdebug_get_function_stack
De functie xdebug_get_function_stack retourneert een array die informatie bevat over de huidige call stack van functies. Elk element van de array is een associatieve array met gegevens over de aanroep. Voor de werking van de functie is de Xdebug-extensie vereist.
Syntaxis
xdebug_get_function_stack();
Voorbeeld
Een eenvoudig voorbeeld van het verkrijgen van de call stack:
<?php
function test() {
var_dump(xdebug_get_function_stack());
}
test();
?>
Resultaat van de code-uitvoering:
[
[
'function' => 'test',
'file' => '/path/to/file.php',
'line' => 4,
'params' => []
],
[
'function' => '{main}',
'file' => '/path/to/file.php',
'line' => 5,
'params' => []
]
]
Voorbeeld
Voorbeeld met geneste functieaanroepen:
<?php
function inner() {
return xdebug_get_function_stack();
}
function outer() {
return inner();
}
$res = outer();
print_r($res);
?>
Resultaat van de code-uitvoering:
[
[
'function' => 'inner',
'file' => '/path/to/file.php',
'line' => 3,
'params' => []
],
[
'function' => 'outer',
'file' => '/path/to/file.php',
'line' => 6,
'params' => []
],
[
'function' => '{main}',
'file' => '/path/to/file.php',
'line' => 8,
'params' => []
]
]
Zie ook
-
de functie
debug_backtrace,
die vergelijkbare informatie over de call stack retourneert