Friday, July 17, 2009

CakePHP 1.2 and “Cannot modify header information” warning. (Not a whitespace problem)

Yesterday I spend too much time trying to solve following problem. While working with CakePHP, writing some login function, I need to use redirection.

But the redirection didn’t work:

Cannot modify header information - headers already sent by (output started at
C:\xampp\htdocs\cool\app\controllers\users_controller.php:1)

Of course I checked all my code and then looked for some solution on Internet. The one, that repeats from page to page was that there is a white space or another character after “?>”.

But not in my case.

In my app everything start to work after I changed the encoding of the files from UTF8 to ANSI. It works also with UTF8 without BOM. It seems to be more or less obvious, but without diving into the encoding issues it is difficult to explain.

And one more thing: the problem is related with PHP in general, not just CakePHP, so Cake stays blessed (so far…).

No comments:

Post a Comment