ob_start("ob_gzhandler") and error handling functions
| From: | IG | Date: | Wed, 20 Dec 2006 14:12:11 +0000 |
| Subject: | ob_start("ob_gzhandler") and error handling functions | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-246073@lists.php.net to get a copy of this message | ||
Hi,
I include a php file at the beginning of every web page in this site. This include file has an error handling function and starts output buffering...
// Start of Error Handler
error_reporting(E_ALL ^ E_NOTICE);
ini_set('log_errors','1');
function ErrHandler($err,$err_string='',$err_file,$err_line)
{
// Do error logging thang
ob_end_clean();// Clear buffer
include('/path/incs/errors/errors.inc');// Output friendly error page
exit();
}
set_error_handler('ErrHandler');
// End of Error Handler
It works great and the error handler kicks in if there is an error on the page and outputs a friendly page instead. I really wanted to gzip the pages by using ob_start("ob_gzhandler") but it doesn't work. I think it is because of the error handler function trying to clear the buffer (see the line ob_end_clean() which I assume becomes ob_end_clean("ob_gzhandler") ). It says on the php functions page- *ob_start()* may not be called from a callback function. If you call them from callback function, the behavior is undefined. If you would like to delete the contents of a buffer, return "" (a null string) from callback function.
As I am new to this- I don't really understand what it is trying to get at. Is there a way of me using my error handler and evoking the ob_start("ob_gzhandler") ?
Thanks.
Ianob_
|ob_start("ob_gzhandler");|