Funzione xdebug_get_function_stack
La funzione xdebug_get_function_stack restituisce un array contenente informazioni sullo stack corrente delle chiamate di funzione. Ogni elemento dell'array è un array associativo con dati sulla chiamata. Per il funzionamento della funzione è richiesta l'estensione Xdebug installata.
Sintassi
xdebug_get_function_stack();
Esempio
Un semplice esempio di ottenimento dello stack delle chiamate:
<?php
function test() {
var_dump(xdebug_get_function_stack());
}
test();
?>
Risultato dell'esecuzione del codice:
[
[
'function' => 'test',
'file' => '/path/to/file.php',
'line' => 4,
'params' => []
],
[
'function' => '{main}',
'file' => '/path/to/file.php',
'line' => 5,
'params' => []
]
]
Esempio
Esempio con chiamate di funzione annidate:
<?php
function inner() {
return xdebug_get_function_stack();
}
function outer() {
return inner();
}
$res = outer();
print_r($res);
?>
Risultato dell'esecuzione del codice:
[
[
'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' => []
]
]
Vedi anche
-
la funzione
debug_backtrace,
che restituisce informazioni simili sullo stack delle chiamate