PHP custom error page

后端 未结 2 708
别那么骄傲
别那么骄傲 2020-12-18 06:29

Everyone says that \"Enabling errors to be shown\" in an active site is bad (due to some security issues).

Now, we have to consider 2 cases:

  1. The site i
2条回答
  •  萌比男神i
    2020-12-18 07:07

    Some time ago I created small system that redirects you to error page when fatal error occurs / uncaught exception was thrown. It was possible with assumption, that every request is handled by one file and ends in this file, so by reaching end of this file I'm sure that everything went OK. With this condition I've set up function to redirect on error page and registered it as shutdown function - so it will be called at the end of all requests. Now in this function I check conditions for clean shutdown and if hey are met, I do nothing and output is flushed to the browser, otherwise buffer is cleaned and only header redirecting to error page is sent.

    Simplified version of this code:

提交回复
热议问题