1

I was a Windows user and used Wamp. Every time a PHP code failed, the browser would display something like this: error in line number xx.

I followed the installation of this tutorial and everything worked.

Now when code fail PHP just display a blank page.

Any sugestions?

(I'm using Ubuntu 10.04).

1
  • 2
    Look for "display_errors" in this site or in the PHP manual.
    – Artefacto
    Aug 3, 2010 at 3:58

4 Answers 4

5

I know this is a old post, but I had the same problem and found out that after error_reporting, there is a option of display_errors, change it to On.

3

Old question, as Gurnarok noted, but still, here's the answer.

The standard LAMP server installation on Ubuntu does this. I simply call it "production" mode, i.e. your pages don't display errors (to your users) when your site goes live. I rather like that it does this, but I was confused at first, as well.

Instead of editing my php.ini file to go into "development" mode, I simply place this at the top of my PHP files (or, PHP file, in my case, since I usually pass everything through index.php):

ini_set('display_errors', true);
error_reporting(E_ALL ^ E_NOTICE);

So, the reason why error_reporting by itself isn't doing the trick, is most likely because display_errors isn't set to true in your php.ini file. The code above should take care of that.

I prefer to exclude the PHP "Notice" notification, such as notifications about non-existent array keys (the most common Notice, in my case), but you're perfectly welcome to simply change this to error_reporting(E_ALL);

Of course, you can set these variables in the php.ini file, I simply prefer it this way, so that when the site goes live, I simply remove those two lines from index.php and I'm in no danger of errors showing up to my users.

1

Find php.ini under /etc/php5/apache2/ and set the value of error_reporting to E_ALL. Like:

error_reporting = E_ALL

Or alternatively check error.log if your virtual host is providing one.

4
  • I pasted that code into the php.ini still seeing a blank page :(
    – alexchenco
    Aug 3, 2010 at 4:22
  • the errors are being save in the error.log file but they are not being displayed in the browser.
    – alexchenco
    Aug 3, 2010 at 4:29
  • @janoChen Don't forget to restart your web server, sudo /etc/init.d/apache2 reload Aug 3, 2010 at 4:31
  • @janoChen Any chance you have a .htaccess or call to ini_set() that might be setting the error_reporting variable to something less verbose?
    – speshak
    Aug 3, 2010 at 4:58
1

Thanks Phil your answer got me thinking and I finally managed to fix an issue thats been bugging me for weeks where my PHP install wasn't displaying errors in the HTML page at all (except sometimes a notice message but never any syntax errors etc). Even though I had all other error settings set to "on" and log_errors set to on and a filename for the log only notices were getting logged to the log file but never any syntax errors. Not very useful on a development server :)

Thought I would post my findings here in the hope that this info can help someone else with the same issue as Google wasn't very helpful with fixing the issue.

In older versions of PHP before PHP 5 I used to always have my error reporting setting in PHP ini set to "E_ALL & E_NOTICE" on my development servers. In later versions of PHP (well with my Ubuntu Oneric install anyways) using this setting seems to cause no output to be displayed at all in the HTML page regardless of the other php.ini settings (like display_errors = on, etc). Setting the values on the fly in a PHP page didnt help either as it seems the php.ini value overrides the per file setting.

I changed the error_reporting value to "E_ALL" only and now it displays syntax errors. The setting recommended in php.ini for a development server (E_ALL | E_STRICT) doesnt work for me either so thanks a lot. +1 to you :)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.