Log errors and instead of showing them show 500 error page in PHP

I am trying to do the following for my site; first of all, it is only for production mode. My goal is to keep all errors hidden from the visitor, but log them and display the internal server internal error page.

The part of hiding these errors is simple - the only thing to do is turn off display_errors.

I am currently using a custom function as my error handler. It just sends 500 error pages, but none of them work. Here's the function:

function error_handler($errno, $errstr) { header($_SERVER['SERVER_PROTOCOL'] . ' 500 Internal Server Error', true, 500); die(); }

This causes another error - no errors are logged because I am using die () at the end of this function.

Any idea how this might work?

+3


source to share


1 answer


Take a look at the error_log function .



+1


source







All Articles