Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- class errorhandler
- {
- var $debug_level = 0;
- function __construct($debug_level = 0)
- {
- // Populate class variables
- $this->debug_level = $debug_level;
- // Take over from PHP error handling
- set_error_handler(array($this, 'handle_error'));
- }
- function handle_error($type, $string, $file, $line, $vars)
- {
- // Decide which type of error it is, and handle appropriately
- switch ($type)
- {
- // Error type
- case FATAL:
- // Select debug level
- switch ($this->debug_level)
- {
- default:
- case 0:
- echo 'Error: '.$string.' in '.$file.' on line'. $line.'<br />';
- print_r($var);
- // Stop application
- exit;
- case 1:
- echo 'There has been an error. Sorry for the inconvenience.';
- // Stop application
- exit;
- }
- case ERROR:
- echo '<pre><b>ERROR</b> ['.$type.'] '.$string.'<br />'."</pre>n";
- break;
- case WARNING:
- echo '<pre><b>WARNING</b> ['.$type.'] '.$string.'<br />'."</pre>n";
- break;
- }
- }
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement