On my development machine, I have PHP set to display all errors (i.e., display_errors is set to on). Unfortunately, PHP sends fatal errors as text/html, which makes reading call stacks a bit of a pain as whitespace is ignored in HTML.
Is there a way to have PHP send pages as text/plain for fatal errors?
A few people in the comments on PHP.net’s
set_error_handler()entry suggested usingregister_shutdown_function()to capture fatal errors. Sure enough, it worked.I created a file,
error.php, with the following:Then added the following to my dev site’s
.htaccessfile:And voilà, fatal errors rendered as plain text.