Error Handling

Error Reporting

// Report all PHP errors.
ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);

This alone doesn’t make PHP show parse errors. The only way to show parse errors is to set display_errors = on in the php.ini file.


  • trigger_error() can be used to trigger a PHP notice, warning, or fatal error.
  • By default a NOTICE is triggered, but the second parameter can set the error level.

trigger_error($error_msg, $error_type);

trigger_error('Test notice!', E_USER_NOTICE);   // Trigger a notice.
trigger_error('Test warning!', E_USER_WARNING); // Trigger a warning.
trigger_error('Test error!', E_USER_ERROR);     // Trigger a error.