Reputation: 15499
I have this variable in a big php script that I want to trace back to where/when and what value it was instantiated. Is there a function/api or debugging techniques to do this?
Upvotes: 0
Views: 2452
Reputation: 6976
If you're using PHPStorm you can set breakpoints and inspect the values of variables.
You'll need xdebug installed as well.
Upvotes: 3
Reputation: 3862
You can use debug_print_backtrace() function. http://php.net/manual/en/function.debug-print-backtrace.php
<?php
function f1() {
f2();
}
function f2() {
f3();
}
function f3(){
echo "<pre>";
debug_print_backtrace();
echo "</pre>";
}
f1();
?>
Output:
#0 f3() called at [/home/xfiddlec/public_html/main/code_47406510.php:9]
#1 f2() called at [/home/xfiddlec/public_html/main/code_47406510.php:5]
#2 f1() called at [/home/xfiddlec/public_html/main/code_47406510.php:18]
Upvotes: -2