Today, a BUG occurs on the website and logs are directly written in the database class to see which SQL statement is faulty. The SQL statement is found, but you do not know where the SQL statement comes from, so I thought, if there is a way to check which method is called for the currently running method and which method is called for the previous method, this class
Today, a BUG occurs on the website and logs are directly written in the database class to see which SQL statement is faulty. The SQL statement is found, but you do not know where the SQL statement comes from, so I thought, if there is a way to check which method is called for the currently running method and which method is called for the previous method, this class
Today, a BUG occurs on the website and logs are directly written in the database class to see which SQL statement is faulty. The SQL statement is found, but you do not know where the SQL statement comes from, so I thought, if there is a way to check which method was called for the currently running method, and which method was called for the previous method, and so on, how nice is the portal address. However, I also thought about it before and searched it online, that is, I did not find any relevant method. Today, a colleague (predecessors) said that such debugging in JAVA is widely used, I searched the PHP stack on the Internet for Stack debugging. I found it and wrote my own method.
// Call the stack function to find the source of the function to facilitate debugging.
Function print_stack_trace ()
{
$ Array = debug_backtrace ();
// Print_r ($ array); // complete information
Unset ($ array [0]);
Foreach ($ array as $ row)
{
$ Html. = $ row ['file']. ':'. $ row ['line']. 'line, call method :'. $ row ['function']."
";
}
Return $ html;
}
I call this method in the core query function of my database. The result is as follows:
D: \ wamp \ www \ meilele \ includes \ cls_mysql.php: Row 471. Call method: query
D: \ wamp \ www \ meilele \ includes \ cls_mysql.php: Row 507, call method: getAll
D: \ wamp \ www \ meilele \ receivdes \ lib_common.php: Row 732. Call getAllCached.
D: \ wamp \ www \ meilele \ includes \ init. php: Row 113. Call load_config
D: \ wamp \ www \ meilele \ index. php: 4 rows. Call method: include_once
At a glance, I found the entrance, which is too powerful. There will be another way to debug later