1. Code
  2. PHP

Quick Tip: Email Error Logs with PHP

Read Time:2 minsLanguages:

In today's video quick tip, we'll review the process of setting custom error handlers with PHP. Along the way, we'll also learn how to log and email those potential errors to ourselves. That way, even when your web application has been deployed, you'll be the first to know when an error is encountered.




If you decide to set your own error handlers, make sure that you:

  • Determine whether or not to die() and kill the page.
  • Provide some level of feedback for the user. If there was a fatal error, let them know in some form!
  • You don't want to email yourself errors when debugging. You can create a $debug variable that, if set to true, we'll bypass the process of emailing you the error, and will, instead, echo the error onto the page. If you need a code snippet for this, just let us know!
Looking for something to help kick start your next project?
Envato Market has a range of items for sale to help get you started.