1. During the execution of the program, record the variables you want to track, the call stack and the parameters of each function call in the corresponding places.
Record this information to the file in a certain format, one variable per line, specific data format Please refer to the code, I won’t go into details here.
2. Now you have all the information (including call stack and parameters) every time the variable is recorded. When you access this program through the browser, this program will read the entire file Analysis,
Display all your debugging information on the page, and it will dynamically refresh with ajax to keep synchronized with your debugging.
Draw a picture, it will be much clearer.
BackTrace is the call stack information. It is not reflected in the picture, it is dynamically refreshed by ajax.
Function:
A few more screenshots of the local machine will be explained:
1. Include files, debugging variables (the above is the program, the following is apache_request_headers() Debug output)
2. Call stack list of a certain function in the drupal system
3. Call parameters of a certain function in the stack
Postscript:
Program It basically implements the functions of debugging and tracking PHP variables, and also comes with the function of viewing call stacks and call parameters.
Nowadays, echo, print_r, var_dump and other system functions are rarely used for debugging output unless necessary. Basically, you can get what you want with this.
Especially for complex systems like drupal, you can clearly know how the program is executed.
Note:
The program is written in php4 , tested on php4.4.8, 5.2.5, and theoretically supports php4, php5.
It has also been tested on linux, window, ie6-7, and firefox, but I still can’t guarantee that it will not work in your environment. If there is an error, please correct it yourself.
Please do not let the log file exceed 5M in size, the browser may crash.
Thank you for reading. For more related articles, please pay attention to the PHP Chinese website (www.php.cn) !