Error reporting in PHP
Some way down the road the default php.ini started to get shipped with settings that stopped the error printing. The default location of this file is /usr/local/lib/php.ini, and the most common settings that controls the error reporting behaviour is listed below:
error_reporting = E_ALL | E_ERROR | ... | E_USER_NOTICE display_errors = On | Off log_errors = On | Off
First of all error_reporting decides what type of errors or messages that will be taken care of in the first place. See php.ini for details. Then you have the options to:
- Print the error as part of the HTML by setting
display_errorstoOn - Log the error to Apaches
error_logby settinglog_errorstoOn - Or both print and log the errors and messages
There is a reason why they stopped to display errors as a default thing. This is because you are risking to leak sensitive information about your server configuration. A way to achive instant information about errors, and keep the rest of your web site safe, is to alter the settings for just the scripts you are working with at run time. It can be done like this:
ini_set('display_errors','On'); error_reporting(E_ALL);
Suggested readings:
- Comments in php.ini section about error reporting
- PHP Manual: error_reporting
- PHP Manual: ini_set
Tags: PHP
February 7th, 2010 at 4:11 pm
Wow that’s weird, I had a similar php error my website! I finally fixed it though