Read more details at http://www.php.net/set_error_handler. You can also find more info about
PHP errors and logging in the PHP manual at http://www.php.net/manual/en/ref.errorfunc.php.
Serious error types (E_ERROR, E_PARSE, E_CORE_ERROR, E_CORE_WARNING, E_COMPILE_ERROR,
and E_COMPILE_WARNING) cannot be intercepted and handled by ErrorHandler::Handler(), but
the other types of PHP errors (E_WARNING for example) can be.
The error-handling method, Handler(), will behave like this:
??? It creates a detailed error message.
??? If the method is configured to do so, the error is e-mailed to the site administrator.
??? If the method is configured to do so, the error is logged to an errors log file.
??? If the method is configured to do so, the error is shown in the response web page.
??? Serious errors will halt the execution of the page. The other ones will allow the page to
continue processing normally.
Let??™s implement the ErrorHandler class in the next exercise.
CHAPTER 3 ?– STARTING THE TSHIRTSHOP PROJECT 51
Exercise: Implementing the ErrorHandler Class
1. Add the following error-handling configuration variables to include/config.php:
// SITE_ROOT contains the full path to the tshirtshop folder
define('SITE_ROOT', dirname(dirname(__FILE__)));
// Application directories
define('PRESENTATION_DIR', SITE_ROOT . '/presentation/');
define('BUSINESS_DIR', SITE_ROOT .
Pages:
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122