debug_print_backtrace()

debug_print_backtrace() — Prints a backtrace.

Built-in function of PHP 8.5. The manual lists it as available in PHP 5, PHP 7, PHP 8. This page is the reference card: signature, parameters and return value, plus the changelog and the example the manual provides.

What it does

debug_print_backtrace() prints a PHP backtrace. It prints the function calls, included/required files and eval()ed stuff.

Signature

debug_print_backtrace(int $options = 0, int $limit = 0): void

Parameters

ParameterTypeWhat it takes
$optionsintThis parameter is a bitmask for the following options: debug_print_backtrace() options DEBUG_BACKTRACE_IGNORE_ARGS Whether or not to omit the "args" index, and thus all the function/method arguments, to save memory. DEBUG_BACKTRACE_PROVIDE_OBJECT Accepted for compatibility with debug_backtrace(), but has no effect: the generated backtrace is rendered as a string and the "object" entry is never printed.
$limitintThis parameter can be used to limit the number of stack frames printed. By default (limit=0) it prints all stack frames.

Return value

No value is returned.

Example

A runnable snippet:

// include.php file function a() { b(); } function b() { c(); } function c(){ debug_print_backtrace(); } a();

Output:

#0 c() called at [/tmp/include.php:10] #1 b() called at [/tmp/include.php:6] #2 a() called at [/tmp/include.php:17] #3 include(/tmp/include.php) called at [/tmp/test.php:3]

See also

debug_backtrace()

All PHP 8.5 built-in functions

Reference card built from the PHP manual page debug_print_backtrace() (PHP documentation, CC BY 3.0). The page is generated from the manual, so the wording of the parameter and return value text follows php.net.