1

I am getting the below warning when i tried to do redirection.please help me to solve this fix this.

Cannot modify header information - headers already sent by (output started at D:\Program Files\xampp\htdocs\cakePHP\cake\libs\debugger.php:673) [CORE\cake\libs\controller\controller.php, line 742]

vinay
  • 127
  • 1
  • 3
  • 5

2 Answers2

2

This error occurs if there is any output before calling header() function. The most common and mostly "invisible" mistake is having whitespaces at the beginning or the end of one or more of your files. Make sure there are none before opening <?php or after closing ?> tags.

Additionally you may also try:

  1. Configure your editor to trim trailing whitespaces before saving the file.
  2. Pre-commit hooks in the SCM of your choice.
  3. The tip from Tomba (see comment below), if you cannot pinpoint the location of your trouble.
benjamin
  • 2,185
  • 1
  • 14
  • 19
  • 1
    Another reader suggested on my original answer: *To avoid such problems, you may safely skip `?>` at the end of your PHP files.* – benjamin Feb 19 '11 at 13:05
  • 1
    I found this script useful for removing whitespace from php files: http://stackoverflow.com/questions/1943727/find-all-files-with-blank-or-ws-at-bof-or-eof – Tomba Feb 19 '11 at 16:15
  • 2
    install the dubug kit and then do `cake whitespace` – dogmatic69 Feb 19 '11 at 21:57
0
ob_start(); 

It's helpful.write ob_start(); in controller

Racil Hilan
  • 24,690
  • 13
  • 50
  • 55