Creating your own exception handling class PHP5 provides a fully functional exception handling class. Why do you need to customize the exception handling program? Because the default Exception Handling does not really properly handle unpredictable results. It only outputs error messages that are no different from common errors. Between standard error handling program and Exception Handling
Creating your own exception handling class PHP5 provides a fully functional exception handling class. Why do you need to customize the exception handling program? Because the default Exception Handling does not really properly handle unpredictable results. It only outputs error messages that are no different from common errors. Between standard error handling program and Exception Handling
Create your own exception
ProcessingClass
PHP5 has provided complete functional exceptionsProcessingClass, why do we need to customize exceptions?ProcessingWhat about programs? Because of the default exceptionProcessingNot properly implement unpredictable resultsProcessing. It is only output and GeneralErrorNo differenceErrorInformation.
StandardErrorProcessingPrograms and exceptionsProcessingOne major difference between them is that an exception can include a cleanup routine that runs automatically when a custom exception is caught. This routine can perfectly clean up and exit elegantly.
Output stack track
PHP5 provides two for debuggingErrorDebug_backtrace () and debug_print_backtrace ()
Read and set configuration variables
// Read the configuration variable $ include_path = ini_get ('include _ path'); // set the configuration variable ini_set ('include _ path', ini_get ('include _ path '). ':/home/fezzik/php ');
Hide from users
ErrorInformation
Set in php. ini
display_errors =offlog_errors =onerror_log = /var/log/php.error.log
You can also use the ini_set function in php to set
ini_set('display_errors', 'off');ini_set('log_errors', 'on');ini_set('error_log', '/var/log/php.error.log');
ErrorReport
You can use error_reporting to set display in PHP.ErrorIn PHP5, a newErrorLevel -- E_STRICT is used to improve the code improvement method, which is the only method not included in E_ALLErrorLevel. Therefore, we need to cover a varietyErrorType, you needErrorThe report is set to E_ALL | E_STRICT.
error_reporting(E_ALL); // everythingerror_reporting(E_ERROR | E_PARSE); // only major problemserror_reporting(E_ALL & ~E_NOTICE); // everything but notices
CustomErrorProcessing
And exceptionsProcessingDifferent, customErrorProcessingCan be usedProcessingAll PHP reportsError, Implemented in the following form:
set_error_handler('pc_error_handler');function pc_error_handler($errno, $error, $file, $line) { $message = "[ERROR][$errno][$error][$file:$line]"; error_log($message);}
Some magic constants are often usedErrorProcessingMedium
_ FILE __,__ LINE __,__ FUNCTION __,__ CLASS __,__ METHOD __
Unit
Test
PHPUnit for PHP4 or PHP5
PHPUnit2 only for PHP5
SimpleTest is a fully functional unit.TestFramework