Home  >  Article  >  PHP Framework  >  The best tool for reading ThinkPHP source code debug_backtrace

The best tool for reading ThinkPHP source code debug_backtrace

咔咔
咔咔Original
2020-11-06 21:21:181754browse
"

This article introduces you to a code debugging artifact debug_backtrace

"

Preface

#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.

1. Instructions for use of debug_backtrace

The following picture is the debugging made by Kaka when debugging and detecting routing grouping. .

The best tool for reading ThinkPHP source code debug_backtrace
Detect routing grouping

The execution roadmap of this code was also drawn by Kaka using a mind map. Please see the picture below.

The best tool for reading ThinkPHP source code debug_backtrace
Detection routing execution roadmap

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.

The best tool for reading ThinkPHP source code debug_backtrace
Usage method

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).

The best tool for reading ThinkPHP source code debug_backtrace
Print results

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.

The best tool for reading ThinkPHP source code debug_backtrace
Adapted code

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.

The best tool for reading ThinkPHP source code debug_backtrace
Print results

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!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn