Nov

27

If you are using CakePHP to develop your website, you may get the error message:
Warning: Cannot modify header information - headers already sent


This error is not uncommon, many people bump into this problem, especially for beginners. This error message makes the problem sound very serious, but the problem itself is not that complicated at how. By interpreting the message ‘literally’, you will find that the default error message instruct you to do something you have already done, for instance: create method in controller.

The actual problem is whitespace, yes, it must be somewhere, a whitespace is hiding somewhere, it can be at view, model or controller, it may not be in the file you are opening, because of the way CakePHP works, you might be editing several files before run the test, so the whitespace at the end of the file could be anywhere in the MVC, if you searched and removed all the whitepace, extra empty line, the error should go away.

What if it still doesn’t work?
The solution is simple, search again! People always miss to search Model, because they focus on controller and view and may assume Model just works. Go and do a thorough search again - Seek, you shall find!

Hope this helps! :)



Similar Posts

Comments

Name (required)

Email (required)

Website

Speak your mind

Sponsors




Links