debug_print_backtrace doesn't work

6.2k views Asked by At

I have PHP 5.3.4 and when I try to use debug_print_backtrace, I don't get anything. When I use vardump, I get an empty array, as you can see below.

index.php:

<?php
define('WP_USE_THEMES', true);

require('./wp-blog-header.php');

var_dump(debug_backtrace());

echo PHP_VERSION;
?>

which returns

...
</html> 
array(0) {
}
5.3.4

Can anyone tell me what is wrong? I am expecting to see everything that was called in the run. Instead I don't see anything.

2

There are 2 answers

2
VolkerK On BEST ANSWER

debug_backtrace() doesn't show you what has been called so far but the current call stack (i.e. more or less where php would jump to on a return statement until it reaches the top level) when the function is invoked.
You might be interested in a profiler like e.g. the one implemented in XDebug plus something to analyse the data like e.g. kcachegrind.

0
Mark Baker On

If you're really after Code Coverage (which it sounds like from your description) then XDebug is useful, or see the responses to this SO question