title: CodeIgniter News Tutorial - Parse Error
body: <p>I'm following the CodeIgniter tutorial (<a href="http://www.codeigniter.com/user_guide/tutorial/news_section.html" rel="nofollow">http://www.codeigniter.com/user_guide/tutorial/news_section.html</a>), when I get to '<a href="http://www.codeigniter.com/user_guide/tutorial/news_section.html#display-the-news" rel="nofollow">Display the news</a>' it isn't made clear where to add the second code block:</p>
  
  <pre><code>public function index()
  {
          $data['news'] = $this-&gt;news_model-&gt;get_news();
          $data['title'] = 'News archive';
  
          $this-&gt;load-&gt;view('templates/header', $data);
          $this-&gt;load-&gt;view('news/index', $data);
          $this-&gt;load-&gt;view('templates/footer');
  }
  </code></pre>
  
  <p>the only way I can interpret the tutorial, is to add it to the News.php controller.</p>
  
  <pre><code>&lt;?php
  class News extends CI_Controller 
  {
  
          public function __construct()
          {
                  parent::__construct();
                  $this-&gt;load-&gt;model('news_model');
                  $this-&gt;load-&gt;helper('url_helper');
          }
  
          public function index()
          {
                  $data['news'] = $this-&gt;news_model-&gt;get_news();
          }
  
          public function view($slug = NULL)
          {
                  $data['news_item'] = $this-&gt;news_model-&gt;get_news($slug);
  
                  if (empty($data['news_item']))
                  {
                          show_404();
                  }
  
                  $data['title'] = $data['news_item']['title'];
  
                  $this-&gt;load-&gt;view('templates/header', $data);
                  $this-&gt;load-&gt;view('news/view', $data);
                  $this-&gt;load-&gt;view('templates/footer');
          }
  }
  </code></pre>
  
  <p>when I add it at the end of application/controllers/News.php I get a parse error:</p>
  
  <pre><code>Parse error: parse error in /server/application/controllers/News.php on line 33
  A PHP Error was encountered
  
  Severity: Parsing Error
  
  Message: parse error
  
  Filename: controllers/News.php
  
  Line Number: 33
  
  Backtrace:
  </code></pre>
  
  <p>if I include it within the News class, I get two PHP errors &amp; a fatal error:</p>
  
  <pre><code>Fatal error: Cannot redeclare News::index() in /server/application/controllers/News.php on line 32
  A PHP Error was encountered
  
  Severity: Warning
  
  Message: Cannot modify header information - headers already sent by (output started at /server/application/controllers/News.php:32)
  
  Filename: core/Common.php
  
  Line Number: 573
  
  Backtrace:
  
  A PHP Error was encountered
  
  Severity: Compile Error
  
  Message: Cannot redeclare News::index()
  
  Filename: controllers/News.php
  
  Line Number: 32
  
  Backtrace:
  </code></pre>
  
  <p>Not sure what else to try?</p>
  
  <p>Thanks in advance.</p>