(PHP 4 >= 4.3.0, PHP 5)
debug_backtrace — Genera un backtrace
$provide_object = true
  ] )debug_backtrace() genera un backtrace PHP.
provide_objectAbilita o meno la popolazione dell'indice "object".
Restituisce un array associativo. Gli elementi che possono essere restituiti sono elencati nella seguente tabella:
| Nome | Tipo | Descrizione | 
|---|---|---|
| function | string | Il nome della funzione corrente. Vedere anche __FUNCTION__. | 
| line | integer | Il numero della linea corrente. Vedere anche __LINE__. | 
| file | string | Il nome del file corrente. Vedere anche __FILE__. | 
| class | string | Il nome della class corrente. Vedere anche __CLASS__ | 
| object | object | L'object corrente. | 
| type | string | Il tipo di chiamata corrente. Se chiamata di metodo, viene restituito "->" is returned. Se chiamata di metodo statico, viene restituito "::". Se chiamata di funzione, non viene restituito niente. | 
| args | array | Se all'interno di una funzione, elenca gli argomenti della funzione. Se all'interno di un file incluso, elenca i nomi del file incluso. | 
| Versione | Descrizione | 
|---|---|
| 5.2.5 | 
        Aggiunto il parametro opzionale provide_object.
        | 
      
| 5.1.1 | Aggiunto l'object corrente come possibile elemento di ritorno. | 
Example #1 debug_backtrace() example
<?php
// filename: /tmp/a.php
function a_test($str)
{
    echo "\nHi: $str";
    var_dump(debug_backtrace());
}
a_test('friend');
?>
<?php
// filename: /tmp/b.php
include_once '/tmp/a.php';
?>
Dà risultati simili ai seguenti quando si esegue /tmp/b.php:
Hi: friend
array(2) {
[0]=>
array(4) {
    ["file"] => string(10) "/tmp/a.php"
    ["line"] => int(10)
    ["function"] => string(6) "a_test"
    ["args"]=>
    array(1) {
      [0] => &string(6) "friend"
    }
}
[1]=>
array(4) {
    ["file"] => string(10) "/tmp/b.php"
    ["line"] => int(2)
    ["args"] =>
    array(1) {
      [0] => string(10) "/tmp/a.php"
    }
    ["function"] => string(12) "include_once"
  }
}