About the debug_backtrace() function in PHP that prints debugging information at the call location

不言
Release: 2023-04-03 08:10:02
Original
1820 people have browsed it

This article mainly introduces the debugging information about the debug_backtrace() function print call in PHP. It has a certain reference value. Now I share it with you. Friends in need can refer to it

debug_backtrace

(PHP 4 >= 4.3.0, PHP 5, PHP 7)

debug_backtrace —Generate a backtrace

Description

##arraydebug_backtrace ([int$options= DEBUG_BACKTRACE_PROVIDE_OBJECT [,int$limit= 0 ]] )

#debug_backtrace () Generates a PHP backtrace.

Parameters

  • options

  • As of 5.3.6, this parameter is the following Bit mask of options:
  • debug_backtrace() option DEBUG_BACKTRACE_PROVIDE_OBJECT DEBUG_BACKTRACE_IGNORE_ARGS Before 5.3.6, the only values that could be used were
    Whether to fill in "object" index.
    Whether to ignore the index of "args", including all function/method parameters, can save memory overhead.
    TRUE

    orFALSE, which were respectively equal to whether to setDEBUG_BACKTRACE_PROVIDE_OBJECToption.

  • limit

  • As of 5.4.0, this parameter can be used to limit the number of stack frames returned. The default is (
  • limit

    =0), which returns all stack frames.

  • Return value

Returns an

array containing many associative arrays. Elements that may be returned:

Elements that may be returned from debug_backtrace() Name function string line integer file string class string object object type string args array Update Log
Type Description
The current function name, see: __FUNCTION__.
The current line number. See: __LINE__.
The current file name. See: __FILE__.
The name of the current class. See __CLASS__
the current object.
The type of the current call. If it is a method, "->" will be returned. If it is a static method, "::" will be returned. If it is a function call, returns null.
If inside a function, this will list the parameters of the function. If it is in an included file, the included file name will be listed.

Example

Example #1debug_backtrace() Example

 
Copy after login

Execution The result returned is similar to the following:

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" } }
Copy after login

The above is the entire article Content, I hope it will be helpful to everyone’s learning. For more related content, please pay attention to the PHP Chinese website!

Related recommendations:

How to use var_export in PHP

About a problem encountered with PHP conditional operators and Solution

Version 5.4.0 limit 5.3.6 provide_object 5.2.5 Added optional parameter . 5.1.1 Added the current
Description
Added optional parameter.
The parameterwas changed tooptions, and the optional parameterDEBUG_BACKTRACE_IGNORE_ARGS# was added ##.
provide_object
object as a possible returned element.

The above is the detailed content of About the debug_backtrace() function in PHP that prints debugging information at the call location. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
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
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!