CakePHP whitespace gotcha
I've been playing around with CakePHP again (I looked at it a couple of years ago) for a small site I'm working on.
I came across this lovely error though when trying to do a redirect:
Warning (2): Cannot modify header information - headers already sent by (output started at /.../tests_controller.php:35) [CORE/cake/libs/controller/controller.php, line 587]
I couldn't see anything wrong with the code - but a quick google found the solution - I had extra whitespace in the controller which was causing the problem.
Removing the extra whitespace after the closing ?> tag fixed it up.
Update: As Danilo pointed out below - this is not a cakephp issue, but a general php one, which occurs if you try to send headers after anything has been output to the browser.
Cheers, Mark


Thanks for pointing that out - and this post was definitely not meant to be a criticism of PHP or CakePHP.
Cheers,
Mark