Jump to content

Codeigniter - Public_T Error


stijn0713

Recommended Posts

Hello, i'm following the codeIgniter tutorial on 'news section' which basically retrieves news items records from database and shows them on a page but according to the MVC principle.

 

Therefore, i just copy paste this code in the news controller:

 

<?php
class News extends CI_Controller {
public function __construct()
{
 parent::__construct();
 $this->load->model('news_model');
}
public function index()
{
 $data['news'] = $this->news_model->get_news();
}
public function view($slug)
{
 $data['news'] = $this->news_model->get_news($slug);
}
}
public function index()
{
$data['news'] = $this->news_model->get_news();
$data['title'] = 'News archive';
$this->load->view('templates/header', $data);
$this->load->view('news/index', $data);
$this->load->view('templates/footer');
}
public function view($slug)
{
$data['news_item'] = $this->news_model->get_news($slug);
if (empty($data['news_item']))
{
 show_404();
}
$data['title'] = $data['news_item']['title'];
$this->load->view('templates/header', $data);
$this->load->view('news/view', $data);
$this->load->view('templates/footer');
}

 

But i get the following error then: Parse error: syntax error, unexpected T_PUBLIC in C:\wamp\application\controllers\news.php on line 21

 

I haven't worked much with OOP but it seems no problem to declare those index and view functions public, right? else the tutorial must be wrong, which i rarely doubt. So what is the problem then?

Link to comment
https://forums.phpfreaks.com/topic/268707-codeigniter-public_t-error/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.