PHP, WEB

Modify error reporting behavior in PHP Part 1

Error reporting behavior can be modified at code level. This is very useful if you don’t have permissions to edit php.ini file.

Here is a simple example to show you how to do it:

  //what should i report?
  ini_set('error_reporting', 'E_ALL');
  //show errors to user?
  ini_set('display_errors', 'Off');
  //log errors?
  ini_set('log_errors', 'On');
  //where should i log errors?
  ini_set('error_log', '/path/to/application/logs/error.log');

Available constants for error_reporting:
E_ERROR E_WARNING E_PARSE E_NOTICE E_CORE_ERROR E_CORE_WARNING E_COMPILE_ERROR E_COMPILE_WARNING E_USER_ERROR E_USER_WARNING E_USER_NOTICE E_STRICT E_RECOVERABLE_ERROR E_DEPRECATED E_USER_DEPRECATED E_ALL

Extra info about constants you can find in PHP manual.