title: CodeIgniter header already sent and ob_start() at the beginning of index.php
body: <p>In my application, I can ensure that there is no such a “un-intentional” whitespace or whatever. I don’t perform “echo” at controller or model, but there is always “header already sent” error on the log file (Nothing shown in browser). I don't have any closing php tag too. The only "suspicious" thing is I load session and input library at both, the model and the controller.</p>
  
  <p>This is actually not a big problem, but the error become terrible if I use CLI request.</p>
  
  <p>After browsing a while, I find this answer at stack overflow:
  <a href="https://stackoverflow.com/a/13783368/755319">https://stackoverflow.com/a/13783368/755319</a>
  It said that I can add ob_start() for output buffering at the beginning of index.php</p>
  
  <pre><code>&lt;?php
  ob_start();
  /*
   *---------------------------------------------------------------
   * APPLICATION ENVIRONMENT
   *--------------------------------------------------------------- 
  </code></pre>
  
  <p>Is is save to do such a thing?</p>
  
  <p><strong>EDIT:</strong> Okay, I might be wrong and miss something here. Is there any programmatic way to find what's wrong? (A program to find wrong php tag, whitespace or something)?</p>
  
  <p><strong>EDIT AGAIN:</strong> The error is only generated in CLI mode. The error is as follow:</p>
  
  <pre><code>&lt;h4&gt;A PHP Error was encountered&lt;/h4&gt;
  
  &lt;p&gt;Severity: Notice&lt;/p&gt;
  &lt;p&gt;Message:  Undefined index: REMOTE_ADDR&lt;/p&gt;
  &lt;p&gt;Filename: core/Input.php&lt;/p&gt;
  &lt;p&gt;Line Number: 351&lt;/p&gt;
  
  &lt;/div&gt;&lt;div style="border:1px solid #990000;padding-left:20px;margin:0 0 10px 0;"&gt;
  
  &lt;h4&gt;A PHP Error was encountered&lt;/h4&gt;
  
  &lt;p&gt;Severity: Warning&lt;/p&gt;
  &lt;p&gt;Message:  Cannot modify header information - headers already sent by (output started at /home/gofrendi/public_html/No-CMS/system/core/Exceptions.php:185)&lt;/p&gt;
  &lt;p&gt;Filename: libraries/Session.php&lt;/p&gt;
  &lt;p&gt;Line Number: 675&lt;/p&gt;
  </code></pre>