Fonction PHP debug_backtrace()
Exemple
Générez une trace PHP :
<?php
function a($txt) {
b("Glenn");
}
function b($txt) {
c("Cleveland");
}
function c($txt) {
var_dump(debug_backtrace());
}
a("Peter");
?>
Définition et utilisation
La fonction debug_backtrace() génère une backtrace PHP.
Cette fonction affiche les données du code qui a conduit à la fonction debug_backtrace().
Renvoie un tableau de tableaux associatifs. Les éléments renvoyés possibles sont :
Name | Type | Description |
---|---|---|
function | string | The current function name |
line | integer | The current line number |
file | string | The current file name |
class | string | The current class name |
object | object | The current object |
type | string | The current call type. Possible calls:
|
args | array | If inside a function, it lists the functions arguments. If inside an included file, it lists the included file names |
Syntaxe
debug_backtrace(options, limit);
Valeurs des paramètres
Parameter | Description |
---|---|
options | Optional. Specifies a bitmask for the following options: DEBUG_BACKTRACE_PROVIDE_OBJECT (Whether or not to populate the "object" index DEBUG_BACKTRACE_IGNORE_ARGS (Whether or not to omit the "args" index, and all the function/method arguments, to save memory) |
limit | Optional. Limits the number of stack frames printed. By default (limit=0) it prints all stack frames |
Détails techniques
Valeur de retour : | Un tableau de tableaux associatifs |
---|---|
Version PHP : | 4.3+ |
Journal des modifications PHP : | PHP 5.4 : Le paramètre optionnel limit a été ajouté PHP 5.3.6 : Le paramètre provide_object a été changé en options et l'option supplémentaire DEBUG_BACKTRACE_IGNORE_ARGS est ajoutée PHP 5.2.5 : Le paramètre optionnel provide_object a été ajouté PHP 5.1.1 : Ajout de l'objet courant comme possible élément de retour |
Référence des erreurs PHP