My 5th book "50 Tips on JavaScript" is on sale. Go get it from
Illustrated guide to 50 of the most interesting JavaScript topics.

How to display php errors when display_errors is set to off

I successfully finished an interactive project for one of my clients. We did a great job and finally I had to install the system on their server. I received the FTP and MySQL information from their IT team, but when I uploaded all my files the site didn't work at the first time. The server didn't show any errors and I wasn't able to find out the problem.
I checked the server's settings by uploading a file with phpinfo() method in it and found that display_errors was set to 'off'. First I tried the following lines of code:
ini_set('display_errors', 1);ini_set('log_errors', 1);ini_set('error_log', dirname(__FILE__) . '/error_log.txt');error_reporting(E_ALL);
But it doesn't work. Then I found the solution - just two lines of code in .htaccess file, placed in the main directory of the site.
php_flag display_errors on php_value error_reporting 7
If you enjoy this post, share it on Twitter, Facebook or LinkedIn. To leave a comment go here.