5

After debugging a CodeIgniter application that were installed into a new development environment, I have started to freak out when seeing white screens with nothing more available. I have been able to solve each and every one of the errors that have caused this, but it has taken seriously way too long time.

PHP error_reporting(E_ALL) & display_errors", 1 is set as well. I even installed Xdebug in hope of getting more output, but no. My logging settings are also working, but nothing is written to the log.

Is there a way to get something informative printed out instead of a complete white screen? It would certainly shorten my time spent on solving the eventual errors that cause this.

Reference: Why does Code Igniter give me a white page?

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
Industrial
  • 41,400
  • 69
  • 194
  • 289

11 Answers11

10

If there's a fatal compilation error, then you may well get a blank page. Try doing a

php -l <filename.php>

against your script

Mark Baker
  • 209,507
  • 32
  • 346
  • 385
4

Look near the top of /index.php for a call to error_reporting() - and make sure it's not changing your php.ini configuration to something else (besides E_ALL).

And since you didn't mention your php.ini configuration, check to ensure you have error_reporting = E_ALL there as well.

Lucas Jones
  • 19,767
  • 8
  • 75
  • 88
Dolph
  • 49,714
  • 13
  • 63
  • 88
4

I've found out, since the time of my question, that nothing seems to ensure that errors are always outputted with PHP, which seems to throw white screens here and there. Regardless of PHP's ini-settings.

I've found out that the best workaround however is to use the following line to ensure that error logging is put into a file easily is accessed and monitored by the application:

ini_set('error_log', MYPATH .'logs/errorlog.log');

As far as I've tested it, when white screens appear - it also gets logged into this errorlog. It seems to be the easiest way to know what happens when things go wrong.

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
Industrial
  • 41,400
  • 69
  • 194
  • 289
3

Grep the files for 'error_reporting', and 'display_errors'. The application might turn it off somewhere.

Also, to be able to see parse errors, you need to set error_reporting/display_errors in the php.ini file, or a .htaccess file. Setting it in the script files will not do and will lead to the white page you describe if there are parsing errors.

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
K. Norbert
  • 10,494
  • 5
  • 49
  • 48
  • Hi, that is done. error_reporting = E_ALL | E_STRICT (? i think?) & display_errors=1 is set in php.ini.... – Industrial May 28 '10 at 16:48
  • Are you sure that the file that you are looking at is executed? Can you put a die('Hello world') at the top and observe the output? – K. Norbert May 28 '10 at 20:15
2

The best thing is to have a checklist of the common problems that could cause this since CodeIgniter's default is already

error_reporting(E_ALL);
  1. Same name controllers and models
  2. using reserved words as methods

The list goes on...

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
Teej
  • 12,764
  • 9
  • 72
  • 93
  • Hi! Yep, I've got a clue on the reasons for white screens to occur, the question were more about if there's any good ways to prevent them from being white and outputting errors instead... – Industrial May 27 '10 at 16:12
2

Aside from everything else posted, also make sure that something masked with the @ (error suppression operator) isn't throwing a fatal error.

Kenaniah
  • 5,171
  • 24
  • 27
1

I had this problem on my freshly installed server. Debian 7. I enabled logging, error reporting, disabled gzip and so on.

However, my PHP-installation did not have MySQL enabled. Enabling MySQL did the trick for me.

Zar
  • 6,786
  • 8
  • 54
  • 76
1

Consider setting PHP's error_log configuration variable -- it can be helpful when you have code setting error_reporting() without your knowledge. Then you can check the error log and see what errors, if any, occurred.

Josh
  • 10,961
  • 11
  • 65
  • 108
  • Error log is set and working, but nothing is outputted in the event of a white screen of death... – Industrial May 27 '10 at 16:07
  • 1
    Hmmm... I'm not sure what else to suggest that hasn't already been suggested. Sorry :-/ – Josh May 27 '10 at 20:39
  • 2
    If something's breaking things so badly that PHP itself dies and can't log anything, it MAY get logged in the webserver's own error_log instead. – Marc B May 28 '10 at 19:21
1

Make sure your logs and cache folder inside /system are chmod'ed to 777.

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
Phil Sturgeon
  • 30,637
  • 12
  • 78
  • 117
0

Ensure that there isn't any whitespace in your files output outside of the CodeIgniter buffer, especially if compression is turned on. You can test this by turning off compression in your CodeIgniter configuration file.

See step two at: http://codeigniter.com/user_guide/installation/upgrade_141.html (Note that while this is for the upgrade, it contains a snippet of the configuration file which explains the problem.)

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
Elliot
  • 1,457
  • 13
  • 40
0

If you by chance have happened to create a cached output for that particular method inside your controller, then it may create a cached version of the page and practically that page is not even running.

The cached error output page is showing up. Please check your cache folder inside the application. It should only contain the index.html file.

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
vs_lala
  • 715
  • 2
  • 8
  • 18