Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

16
  • 120
    +1 This is the actual correct answer. I don't know why people are getting hung up on "you cannot recover from fatal errors"--the question didn't say anything about recovering. Commented Nov 1, 2011 at 21:53
  • 21
    Thanks, good one. Recovering from fatal errors (memory limits for example) is not something that I would try to do, but making these errors discoverable (without customer submitting a support ticket) makes all the difference.
    – Ilija
    Commented Feb 11, 2012 at 10:51
  • 3
    Using basic mail: mail("[email protected]", "My Site: FATAL ERROR", "Details: " . $errno . ' ' . $errstr . ' ' . $errfile . ' ' . $errline);
    – Eric
    Commented Jun 17, 2013 at 7:02
  • 4
    @ScottNicol Slava V is correct, because the shutdown function is called every time the script finishes running. With the way the code is written now, an email will be sent on EVERY page load.
    – Nate
    Commented Jan 21, 2014 at 3:46
  • 5
    Note: this is not a 100% correct answer. Any place that uses an @ symbol to ignore errors will still SET the last error (so you can handle errors). So your script finishes without a problem but the register_shutdown_function still thinks an error happened. Only since PHP 7 though have they had a function error_clear_last().
    – Rahly
    Commented Aug 24, 2017 at 23:56