This article will introduce you to a debugging tool that can replace echo, print_r, var_dump, and other system functions, as well as call stack and parameter tracing functions. in short, it is the web version of debug_backtrace. principle:
1. in the process of program execution, record the variables you want to track and the parameters of the call stack and each function call,
Record the information to the file in a certain format, with one variable row. for details about the data format, see the code.
2. now we have all the information (including the call stack and parameters) for every variable record. when you access this program through a browser, this program will read and analyze the entire file,
All your debugging information is displayed on the page, and it will be dynamically refreshed by ajax to keep syncing with your debugging.
Draw a picture. it is much clearer.
BackTrace is the call stack information, which is not shown in the figure. it is dynamically refreshed by ajax.
Function:
Next, let's take a few pictures of the local machine:
1. include the file and debug the variable (above is the program, below is the debug output of apache_request_headers)
2. list of call stacks of a function in the drupal system
3. call parameters of a function in the stack
Postscript:
The program basically implements debugging and tracking php variables. It also comes with the call stack and call parameter viewing functions.
Now echo, print_r, var_dump, and other system functions. if not necessary, I have rarely used them for debugging and output. basically I can use this to get what I want.
Especially complex systems like drupal can clearly understand how programs are executed.
Note:
The program is written in php4 and tested on php4.4.8 and 5.2.5. In theory, php4 and php5 are supported.
Linux, window, ie6-7, firefox are also tested, but still do not dare to ensure that in your environment without errors, if there is, please correct.
Please prevent the log file from exceeding 5 MB, and the browser may crash.
Http://www.jb51.net/codes/20851.html