I’m trying to change the way the error files from
system/application/errors work by logging the errors and showing a 404 page instead. However, sometimes the error occurs in the middle of a page and I need to display only the error page.
I’ve tried to check if the headers are sent and cleaning the output buffer but it didn’t work.
Update: My question seems to confuse people so I’ll clarify. My intention is to show a custom 500 page in the event that an error occurs some time after a part of content was sent and log the conditions in which the error occurred so that a user won’t see an ugly page and a hacker won’t see leaks. The main problem lies in removing the content before the error.
Strategies that didn’t work so far:
- checking using
$CI = & get_instance(); $CI->output->set_output('only the 500 message');
- adding an
_output($data)function to the controller and echo-ing only the 500 message if a certain pattern found in the
system/application/errors/*.phpfiles is found
Any help is much appreciated.
Are you looking for custom 404 error pages for codeigniter?
Do you mean changing the default way that CI errors are handled?
Check these two guides out the check out how to handle codeigniter and PHP errors.
Turn on error logging to text file or something, and then turn off all php errors (this is set in index.php) with
you should change from E_ALL to E_ERROR to show only messages for fatal run time problems. This will hide all php errors except those that will halt your script execution.
On this page scroll down to May 27 2008.
If headers have not been sent, it does a