Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

PHP errors NOT being displayed in the browser [Ubuntu 10.10]

I'm new to PHP and the whole LAMP stack but I've managed to get it up and running on my Ubuntu 10.10 system. Everything seems to be working with the exception of error reposting in the browser which I just can't seem to get working (and which I can't work without!).

I've read a number of article and other threads which indicate that the following values should be applied in the file /etc/php5/apache2/php.ini:

  • display_errors = On
  • display_startup_errors = On

I've restarted apache2 and even restarted my computer but for the life of me I just can't get it working. I've even tried using phpinfo() function which reports that these settings are as I've set them so I know it's picking up the correct configuration file but nothing!

Any help would be welcome.

like image 587
raven-king Avatar asked Feb 19 '11 11:02

raven-king


People also ask

How do I show PHP errors in Ubuntu?

Quickly Show All PHP Errors The quickest way to display all php errors and warnings is to add these lines to your PHP code file: ini_set('display_errors', 1); ini_set('display_startup_errors', 1); error_reporting(E_ALL);

Why does PHP not show errors?

The display_errors directive can be set to " on " in the PHP. ini file. This will display all errors including syntax and parse errors that are not displayed by only calling the ini_set function in the PHP code. Note that the display_errors directive must be set to " off " if the application is in production.

How do I turn off PHP errors?

To turn off or disable error reporting in PHP, set the value to zero. For example, use the code snippet: <? php error_reporting(0); ?>


2 Answers

Don't just enable the first occurrence of display_errors in the php.ini file. Make sure you scroll down to the "real" setting and change it from Off to On.

The thing is that if you settle with changing (i.e. uncomment + add = On) by the very first occurrence of display_errors your changes will be overwritten somewhere on line 480 where it's set to Off again.

like image 87
dbm Avatar answered Sep 21 '22 12:09

dbm


I had the same problem - solved it by setting display_errors = On in both php.ini files.

/etc/php5/apache2/php.ini /etc/php5/cli/php.ini 

Then restarting Apache:

sudo /etc/init.d/apache2 restart 

Hope this helps.

like image 45
Alex Avatar answered Sep 18 '22 12:09

Alex