Home>Article>Backend Development> How to use PHP error handling function debug_backtrace()?

How to use PHP error handling function debug_backtrace()?

藏色散人
藏色散人 Original
2019-03-09 14:18:49 2514browse

How to use PHP error handling function debug_backtrace()?

php debug_backtrace() functionis used to generate a PHP backtrace, that is, to generate a PHP backtrace (backtrace).

Syntax:

debug_backtrace(provide_object)

Parameters:

provide_object: Specify whether to fill the object index. The type of provide_object is boolean.

Return value:

The debug_backtrace() function returns an associative array. The following list is the possible returned elements:

## function string The name of the current function. line integer Current line number. file string Current file name. class string Current class name object object Current object name. type string args array
Name Type Description
Specifies the current call type.

is used for method calls. (returns "->")

is used for static method calls. (Return "::")

is used for function calls. (If nothing is returned, it is empty)

If inside the function. (This lists the function parameters.)

If in an included file. (This lists the included file names.)

Code example:


"; var_dump(debug_backtrace()); } demo('php');

Output:


正在学习:php array (size=1) 0 => array (size=4) 'file' => string 'D:\wamp\www\test\demo.php' (length=25) 'line' => int 7 'function' => string 'demo' (length=4) 'args' => array (size=1) 0 => &string 'php' (length=3)

Related recommendations: "

PHP Tutorial"

This article introduces the PHP error handling function debug_backtrace(). I hope it will be helpful to friends in need!

The above is the detailed content of How to use PHP error handling function debug_backtrace()?. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn