Xdebug is an open source PHP program debugger (a debug tool that can be used to track, debug, and analyze the health of PHP programs.
First, stacked error debugging
First of all, look at Xdebug's most basic function----------------------stack debug, code is simple, just have a function called T1, function require a nonexistent PHP file
function T1 () {require ' notexists.php ';} T1 ();
The execution results are as follows, and you can see very detailed error messages. The program executes the T1 function first, and then throws a fatal error in line 11 of the code.
Second, calculate the execution time of the script and the memory consumed
If you do not use Xdebug, the Microtime function is used to calculate the execution time, or the consumed memory is calculated through the Memory_get_usage/memory_get_peak_usage function. After installing Xdebug, you can use Xdebug_time_index and xdebug_memory_usage/xdebug_peak_memory_usage to implement. Note that the Xdebug_time_index () function returns the time that the script started executing from Mian to xdebug_time_index function execution.
The code is as follows:
echo "Xdebug_memory_usage:". Xdebug_memory_usage (); Echo ' Xdebug_time_index: '. Xdebug_time_index (); $arr =array (); for ($i =1; $i <=10000;++ $i) {Array_push ($arr, $i);} echo "Xdebug_memory_usage:". Xdebug_memory_usage (); Echo ' Xdebug_time_index: '. Xdebug_time_index (); while (!is_null ( Array_pop ($arr)) {}echo "xdebug_memory_usage:". Xdebug_memory_usage (); Echo ' Xdebug_time_index: '. Xdebug_time_index (); echo "Xdebug_peak_memory_usage:". Xdebug_peak_memory_usage ();//Display memory spikes
Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.
Xdebug usage Daquan (i)