Do you want to know which files are called by the current function? If we know these paths, we can well understand the execution process of the program. This is very important and is also the basis for understanding other people's programs. So here I will give you Let’s introduce a stack debugging method in php. It is actually a function built into phpdebug_backtrace();
The following is a brief introduction. You still need to read the manual for details. Programmers who like to read manuals are The promising
<code>$statcks = debug_backtrace(); $tmp_arr = array(); <span>if</span>(!$stacks) <span>return</span> $tmp_arr; foreach($stacks as $k=>$v) { $tmp[$k][<span>'file'</span>] = isset($v[<span>'file'</span>]) ? $v[<span>'file'</span>] : <span>'--'</span>; $tmp[$k][<span>'line'</span>] = isset($v[<span>'line'</span>])? $v[<span>'line'</span>] : <span>'--'</span>; $tmp[$k][<span>'function'</span>] = isset($v[<span>'function'</span>]) ? $v[<span>'function'</span>] : <span>'--'</span>; } Array ( [<span>0</span>]<span> =></span> Array ( [file]<span> =></span><span>D</span>:\wwwroot\CodeIgniter\application\controllers\finance\channel.php [line]<span> =></span><span>128</span> [<span>function</span>]<span> =></span> get_total_rows ) [<span>1</span>]<span> =></span> Array ( [file]<span> =></span> -- [line]<span> =></span> -- [<span>function</span>]<span> =></span> index ) [<span>2</span>]<span> =></span> Array ( [file]<span> =></span><span>D</span>:\wwwroot\CodeIgniter\application\controllers\finance\channel.php [line]<span> =></span><span>46</span> [<span>function</span>]<span> =></span> call_user_func ) [<span>3</span>]<span> =></span> Array ( [file]<span> =></span> -- [line]<span> =></span> -- [<span>function</span>]<span> =></span> get_nav ) [<span>4</span>]<span> =></span> Array ( [file]<span> =></span><span>D</span>:\wwwroot\CodeIgniter\system\core\CodeIgniter.php [line]<span> =></span><span>360</span> [<span>function</span>]<span> =></span> call_user_func_array ) [<span>5</span>]<span> =></span> Array ( [file]<span> =></span><span>D</span>:\wwwroot\CodeIgniter\index.php [line]<span> =></span><span>205</span> [<span>function</span>]<span> =></span> require_once ) )</code>
Here is the printed array, very good
Copyright statement: This article is an original article by the blogger and may not be reproduced without the permission of the blogger.
The above introduces stack debugging in PHP, including aspects of it. I hope it will be helpful to friends who are interested in PHP tutorials.