Prev | Current Page 115 | Next

Emilian Balanescu and Cristian Darie

"Beginning PHP and MySQL E-Commerce: From Novice to Professional, Second Edition"

php:
/* Set user error handler method to ErrorHandler::Handler method */
public static function SetHandler($errTypes = ERROR_TYPES)
{
return set_error_handler(array ('ErrorHandler', 'Handler'), $errTypes);
}
?– Note The second parameter of set_error_handler() specifies the range of errors that should be intercepted.
E_ALL specifies all types of errors, including E_NOTICE errors, which should be reported during web
site development.
CHAPTER 3 ?–  STARTING THE TSHIRTSHOP PROJECT 56
When called, ErrorHandler::Handler() constructs the error message with the help of a method named
ErrorHandler::GetBacktrace() and forwards the error message to the client??™s browser, a log file, the administrator
(by e-mail), or a combination of these; the forwarding behavior can be configured by editing config.php.
GetBacktrace() gets the backtrace information from the debug_backtrace() function (introduced in PHP 4.3.0)
and changes its output format to generate an HTML error message similar to a Java error. It isn??™t important to
understand every line in GetBacktrace() unless you want to personalize the backtrace displayed in case of an
error. The 2 parameter sent to GetBacktrace() specifies that the backtrace results should omit the first two
entries (the calls to ErrorHandler::Handler() and ErrorHandler::GetBacktrace()).
You build the detailed error string in ErrorHandler::Handler(), including the backtrace information:
$backtrace = ErrorHandler::GetBacktrace(2);
// Error message to be displayed, logged or mailed
$error_message = "\nERRNO: $errNo\nTEXT: $errStr" .


Pages:
103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127
wsparcie sprzedaży Zamykanie naczynek kraków noclegi świnoujście SPA papa na dach