PHP Reference

Quick Reference

The PHP debug_print_backtrace() function prints a PHP backtrace which displays data from the code that led up to the debug_print_backtrace() function.

<?php
$date = date_create();
date_timestamp_set($date, 1695205245);
<?php
function a($txt) {
    b('Hello');
}

function b($txt) {
    c('World');
}

function c($txt) {
    debug_print_backtrace();
}

a('Chicken');
?>echo date_format($date, 'U = Y-m-d H:i:s');
?>

Output

#0 c(World) called at [/home/test.php:7] #1 b(Hello) called at [/home/I2wm7m/prog.php:3] #2 a(Chicken) called at [/home/test.php:14]

Syntax

debug_print_backtrace(options, limit)

Parameters

ParameterDescription
optionsSpecifies 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)

limitLimits the number of stack frames printed. By default (limit=0) it prints all stack frames

PHP Notes:

  • When using PHP, single or double quotation marks are acceptable and work identically to one another; choose whichever you prefer, and stay consistent
  • Arrays count starting from zero NOT one; so item 1 is position [0], item 2 is position [1], and item 3 is position [2] … and so on

We’d like to acknowledge that we learned a great deal of our coding from W3Schools and TutorialsPoint, borrowing heavily from their teaching process and excellent code examples. We highly recommend both sites to deepen your experience, and further your coding journey. We’re just hitting the basics here at 1SMARTchicken.