The Importance of Error Reporting in Website Development

January 07, 2010
Displaying errors, warning, or notices is important in all stages of website development. During initial development, it provides line numbers where errors occur and developers spot and fix all errors faster. During testing, it shows warnings and notices when running test scenarios, and tracks all bugs. During production it writes errors to a log file, and sends an email to the website administrator for immediate attention.
 
When programming in PHP, a popular website programming language, error reporting functions display or write all errors, warnings or notices that PHP code produces into a log file. This is very useful and important to overall website performance. A company came to us and said they had a website with poor performance; page loading times were too slow. We copied their code to our server with error reporting turned on and saw 60 warnings during home page loading. This was hidden on their server which had no error reporting. We went to the code and fixed the problems. This had a dramatic effect on website loading times; they went from 6.12 seconds to 0.25 seconds immediately for all pages.   
 
The sample of errors below clearly explains the problem and where the website developer should look in the code.
 
Sample of error, warning and notice
 
Parse error: syntax error, unexpected T_VARIABLE in /var/www/vhosts/domain.com/httpdocs/index.php on line 11
Warning: fwrite(): supplied argument is not a valid stream resource in /var/www/vhosts/domain.com/httpdocs/index.php on line 56
Notice: Undefined variable: var in /var/www/vhosts/domain.com/httpdocs/index.php on line 21
 
Below are the easy instructions used to enable error reporting in PHP.
 
How to turn on Error Reporting in PHP
 
-          In PHP code
ini_set('display_errors',1);
error_reporting
(E_ALL|E_STRICT);
This will display all error, warnings ant notices.
 
-          In php.ini
error_reporting = E_ALL
 
-          In .htaccess
php_flag display_errors on
php_value error_reporting 7