On 19/10/2021 21:52, iio7@xxxxxxxxxxxxxx wrote:
Normally an error in the output generating code, whether generated
with a template engine or just by using PHP as the template engine
(which is what I do), will display AFTER any prior output has already
reached the browser.
Is it possible to make a custom error and exception handler display a
clean page with a custom message without the use of output buffering?
Yes, you can wrap those parts of code that _might_ cause errors in a
try/catch block. From there, you can do whatever you like with the
thrown exception. Typically, the errors will still be logged to the
error log, but you can determine how you would like to handle any
problems, such as generating null objects rather than the one you
intended to create, or just show a custom error message to the user.
--
Ashley Sheridan
https://www.ashleysheridan.co.uk