3 ms·
I believe your trickery involves capturing the output buffer and grep'ing for a fatal error, yes? We thought of doing that, but our site commands too much traff
by dolinsky 17y ago
I believe your trickery involves capturing the output buffer and grep'ing for a fatal error, yes? We thought of doing that, but our site commands too much traffic for that to be a feasible option. If it's something less intrusive, I'm all ears.
- wvenable 17y agoYou can't capture the output buffer on a fatal error; the script just aborts. You do have to wait till the end of your script to write your output otherwise this doesn't work very well but here is some (simplified) code: $errorTemplate = file_get_contents("errortemplate.html"); $templates = explode('%error%', $text, 2); ini_set('error_prepend_string', $templates[0]); ini_set('error_append_string', $templates[1]); ini_set('html_errors', '0'); The errortemplate.html file is a static HTML file that can contain anything you want. Ours is themed up just like any other page on our website. When a fatal error is triggered, the text %error% will be replaced with the fatal error text. We place that into a form using a hidden textarea so our users can submit it to us. <textarea style="display: none;">%error%</textarea> The server log will contain the fatal error, so you don't care about users submitting it you can just wrap it in a comment. <!-- %error% --> And that's all there is to it.