Wrong me in PHP, we use set_error_handler for processing, if an exception occurs, we use Set_exception_handler, but in debugging we can also use the
Debug_print_backtrace and Debug_backtrace Call stack information printing
Use of Set_error_handler
My ERROR[$errno] $errstr
\ n "; echo "Fatal error on line $errline in file $errfile"; echo ", PHP". Php_version. " (" . Php_os. ")
\ n "; echo "Aborting ...
\ n "; Exit (1); Break Case E_user_warning:echo "My WARNING[$errno] $errstr
\ n "; Break Case E_user_notice:echo "My NOTICE[$errno] $errstr
\ n "; Break Default:echo "Unknown error type: [$errno] $errstr
\ n "; Break }/* Don ' t execute PHP Internal Error handler */return TRUE;} function to test the error handlingfunction Scale_by_log ($vect, $scale) {if (!is_numeric ($scale) | | $scale <= 0) {Trigger_error ("log (x) for x <= 0 are undefined, you used:scale = $scale", e_user_error); } if (!is_array ($vect)) {trigger_error ("Incorrect input vector, array of values expected", e_user_warning); return null; } $temp = Array (); foreach ($vect as $pos = + $value) {if (!is_numeric ($value)) {Trigger_error ("value at position $pos I s not a number, using 0 (zero) ", e_user_notice); $value = 0; } $temp [$pos] = log ($scale) * $value; } return $temp;} $old _error_handler = Set_error_handler ("MyErrorHandler");? >
Use of Set_exception_handler
Gettrace (); foreach ($trace as $key + $stackPoint) {//Returns an exception similar to the exception description information $trace [$key] [' args '] = Array_map (' GetType ', $tra ce[$key [' args ']); }//Format exception information $result = Array (); foreach ($trace as $key = + $stackPoint) {$result [] = sprintf ($traceline, $key, $stackPoint [' file '], $stackPoint [' line '], $stackPoint [' function '], implode (', ', $stack point[' args ')); }//Trace always ends with {main} $result [] = ' # '. + + $key. ' {main} '; Write tracelines into main template $msg = sprintf ($msg, Get_class ($exception), $exception-> ; GetMessage (), $exception->getfile (), $exception->getline (), implode ("\ n", $result), $ex Ception->getfile (), $exception->getline ()); Error_log ($msg);}? >