debug_print_backtrace

Prints a backtrace

Syntax

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

Parameters

options

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 thus all the function/method arguments, to save memory.
limit

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

Return

No value is returned.

Examples

void

<?

function myfunction1($myarg1, $myarg2)
{
    $myarg1 += 1;
    $myarg2 += 1;

    myfunction2($myarg1, $myarg2);
}
function myfunction2($myarg1, $myarg2)
{
    $myarg1 += 1;
    $myarg2 += 1;

    debug_print_backtrace();
}

myfunction1(0, 1);

?>
#0 myfunction2(2, 3) called at [/home/user/public_html/file.php:8]
#1 myfunction1(1, 2) called at [/home/user/public_html/file.php:18]

options | DEBUG_BACKTRACE_PROVIDE_OBJECT

<?

function myfunction1($myarg1, $myarg2)
{
    $myarg1 += 1;
    $myarg2 += 1;

    myfunction2($myarg1, $myarg2);
}
function myfunction2($myarg1, $myarg2)
{
    $myarg1 += 1;
    $myarg2 += 1;

    $options = DEBUG_BACKTRACE_PROVIDE_OBJECT;

    debug_print_backtrace($options);
}

myfunction1(0, 1);

?>
#0 myfunction2(2, 3) called at [/home/user/public_html/file.php:8]
#1 myfunction1(1, 2) called at [/home/user/public_html/file.php:20]

options | DEBUG_BACKTRACE_IGNORE_ARGS

<?

function myfunction1($myarg1, $myarg2)
{
    $myarg1 += 1;
    $myarg2 += 1;

    myfunction2($myarg1, $myarg2);
}
function myfunction2($myarg1, $myarg2)
{
    $myarg1 += 1;
    $myarg2 += 1;

    $options = DEBUG_BACKTRACE_IGNORE_ARGS;

    debug_print_backtrace($options);
}

myfunction1(0, 1);

?>
#0 myfunction2() called at [/home/user/public_html/file.php:8]
#1 myfunction1() called at [/home/user/public_html/file.php:20]

limit

<?

function myfunction1($myarg1, $myarg2)
{
    $myarg1 += 1;
    $myarg2 += 1;

    myfunction2($myarg1, $myarg2);
}
function myfunction2($myarg1, $myarg2)
{
    $myarg1 += 1;
    $myarg2 += 1;

    $options = DEBUG_BACKTRACE_PROVIDE_OBJECT;
    $limit = 1;

    debug_print_backtrace($options, $limit);
}

myfunction1(0, 1);

?>
#0 myfunction2(2, 3) called at [/home/user/public_html/file.php:8]

PHP

Home Menu