error handling - How can I get php to return 500 upon encountering a fatal exception? - Stack Overflow

PHOTO EMBED

Wed Nov 04 2020 08:31:33 GMT+0000 (Coordinated Universal Time)

Saved by @Bujhm #php

function my_error_handler()
{
  $last_error = error_get_last();
  if ($last_error && $last_error['type']==E_ERROR)
      {
        header("HTTP/1.1 500 Internal Server Error");
        echo '...';//html for 500 page
      }
}
register_shutdown_function('my_error_handler');
content_copyCOPY

https://stackoverflow.com/questions/1555862/how-can-i-get-php-to-return-500-upon-encountering-a-fatal-exception/8851820