Home > Article > PHP Framework > The best tool for reading ThinkPHP source code debug_backtrace
"This article introduces you to a code debugging artifact debug_backtrace
"
#When reading the source code, Kaka always uses the editor to track the code, but sometimes there is a problem when going back.
Even if the editor provides a fallback route for code tracking, sometimes it still takes a while to check it.
I accidentally discovered a PHP debugging function debug_backtrace
.
This function can clearly see the execution route of the code (provided that the code is changed to a certain extent).
Next, Kaka will briefly explain and revise this function to create its own development tool.
The following picture is the debugging made by Kaka when debugging and detecting routing grouping. .
The execution roadmap of this code was also drawn by Kaka using a mind map. Please see the picture below.
Let’s use this artifact in the code and see what happens.
The method of use is to assign this function to a variable and then print the variable.
Pay attention to the printed results. There are file names, line numbers, method names, and class names, but there will still be some useless ones. Things (useless here refers to personal circumstances, but it is very clear and convenient when looking at the class information).
Simple processing of the artifact
At present, only a few clicks are needed A simple message is enough. The code adapted by Kaka is as follows.
Redefine a variable and store only the required information, then use the inversion of the array.
Then you can clearly see the execution process by looking at the print results.
After debugging, it is consistent with the route drawn by Kaka using mind mapping.
“Persistence in learning, persistence in blogging, and persistence in sharing are the beliefs that Kaka has always upheld since his career. I hope Kaka’s article on Nuoda Internet can bring you a little bit of help. I’m Kaka, see you next time.
”
The above is the detailed content of The best tool for reading ThinkPHP source code debug_backtrace. For more information, please follow other related articles on the PHP Chinese website!