Tuesday, 8 March 2011

Invisible trouble

Perhaps you never encountered this. Happened to me once before and today I managed to fix it.
We use CodeIgniter PHP Framework as main tool in our work on this particular project. Me and my co-workers are developing rather huge website.

I am not going to write it's url here, because it is not fully online yet and I would be embarrassed to let you see all it's flaws ;-)  

The main page (home), on it's top, started to display some error messages like "Headers already sent ... blah, blah" and mentioned Session.php library.

I know that it like happens if one would print or echo something in the same method containing the PHP header() function later.

But there was not supposed to be any header() statements on that page/method.

I googled up some tips about it. The most significant advice was that there are some space characters outside of opening or closing PHP tags in a controller.

Notepad++ did not show any spaces there. Nor did the regular Notepad show anything.

This is a kind of thing that makes my self esteem disappear, in seconds :-/ Don't know when or if I am going to fix it or when.

Then I remembered to try again but using GVim. I was not surprised to see some one or two strange characters on the beginning of controller file, because it was the only logical cause for this error.

It also proved to me that I should use GVim as a main editor.

Why this happened? I suppose that is because different text editors open, save and close files in a non consistent manner, or do it in a different way.

1 comment:

  1. lamp beginner4 June 2011 01:03

    I have similar problems from time to time, while using different editors and opening/changing all kinds of files on several developing environments/servers. Some editors can not display such strange characters which appear in files due to the above mentioned circumstances. I'm using UltraEdit and Eclipse in JSP applications and when I run in to the same problem, since servers are Unix HP - I open the file in VI editor :) Unix prompt, 'vi filename'

    To my expirience, VI shows EVERYTHING :) Not user friendly, poor looks, but saves the day :)

    ReplyDelete