note 51205 deleted from language.exceptions by nlopess
| From: | nlopess@php.net | Date: | Thu, 24 Mar 2005 23:29:28 +0000 |
| Subject: | note 51205 deleted from language.exceptions by nlopess | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-86921@lists.php.net to get a copy of this message | ||
Note Submitter: Bill Kuker
----
In an application made of many pages each of which includes a standard header and footer I found
myself wanting to be able to define a top level try / catch block with a default error screen.
Unfortunatly you cant put 'try{' in header.inc and '}catch...' in footer.inc. My
solution is to do away with the footer and just require_once a header.inc that looks like this:
//Output header
try{
ob_start();
include($_SERVER['PHP_SELF']);
ob_end_flush();
} catch (Exception $e){
ob_end_clean();
//error screen
}
//Output Footer
die();
This in effect wraps the including page in the try / catch block. Note the importance of where I
require_once vs where I include, and that you would not want to run header.inc directly ;)