5Dec/110
Codeigniter header already sent error using json header
Getting this error when moving from development server to staging server and getting this error.
Severity: Warning --> Cannot modify header information - headers already sent
The error shows up if you are doing all of the following.
1. Change header using
$this->output->set_content_type('application/json');
2. Outputting using echo (which is not recommended by Codeigniter).
3. In php.ini, have output_buffering set very small, like 0.
Solution
There are two solutions to this issue.
1. Increase the output_buffering enough so to buffer your echo. (this is a hack)
2. Recommended solution is to replace echo with CIs built in $this->output->set_output('content') method.