PHP debug_backtrace() function
Example
Generate PHP backtrace:
<?php function a($txt) { b("Glenn"); } function b($txt) { c("Cleveland"); } function c($txt) { var_dump(debug_backtrace()); } a("Peter"); ?>
The output of the above code is similar to this:
Array ( [0] => Array ( [file] => C:\webfolder\test.php [line] => 6 [function] => c [args] => Array ( [0] => Cleveland ) ) [1] => Array ( [file] => C:\webfolder\test.php [line] => 3 [function] => b [args] => Array ( [0] => Glenn ) ) [2] => Array ( [file] => C:\webfolder\test.php [line] => 11 [function] => a [args] => Array ( [0] => Peter ) ) )
Definition and Usage
The debug_backtrace() function generates a backtrace (traceback).
This function displays the data generated by the code of the debug_backtrace() function.
Return an associative array. The possible elements returned may be as follows:
Naam | Type | Beschrijving |
---|---|---|
function | string | Huidige functienaam |
line | integer | Huidige regelnummer |
file | string | Huidige bestandsnaam |
class | string | Huidige classnaam |
object | object | Huidig object |
type | string |
Huidige aanroepstype. Mogelijke aanroepen:
|
args | array | Als je in een functie bent, geef de functieparameters op. Als je een geciteerde bestand hebt, geef het bestandsnaam op. |
Syntaxis
debug_backtrace(opties,limiet);
Parameters | Beschrijving |
---|---|
opties |
Optioneel. Specificeer de bitmasker voor de volgende opties:
|
limiet | Optioneel. Beperk het aantal retournerende stack frames. Standaard is dit (limiet=0) retourneert alle stack frames. |
Technische details
Retourneringswaarde: | Geen |
---|---|
PHP versie: | 4.3+ |
PHP update log |
PHP 5.4: Voegde optionele parameter toe limiet. PHP 5.3.6: Parameter provide_object veranderd in optiesen voegde de optionele parameter DEBUG_BACKTRACE_IGNORE_ARGS toe. PHP 5.2.5: Voegde optionele parameter toe provide_object. PHP 5.1.1: Voegde huidige toe object Voor mogelijke elementen. |