-
vojkoz
Newbie
-
Posts: 8
Threads: 3
Joined: Nov 2020
Reputation:
0
ParseError
syntax error, unexpected 'public' (T_PUBLIC), expecting end of file
APPPATH\Controllers\News.php at line 23
Code: 16 {
17 $model = new NewsModel();
18
19 $data['news'] = $model->getNews($slug);
20 }
21 }
22
23 public function index()
24 {
25 $model = new NewsModel();
26
27 $data = [
28 'news' => $model->getNews(),
29 'title' => 'News archive',
30 ];
01-14-2021, 10:22 AM
(This post was last modified: 01-14-2021, 10:25 AM by captain-sensible.)
i can only see what you have posted but index method is missing a curly brace, above that it looks un complete could be:
Code: public function index()
{
$model = new NewsModel();
$data['news'] = $model->getNews($slug);
$data = [
'news' => $model->getNews(),
'title' => 'News archive', // there is no other item so "," not needed
];
} //end of method
Arch Book CodeIgniter4 on Apache(pages 92-114)
-
vojkoz
Newbie
-
Posts: 8
Threads: 3
Joined: Nov 2020
Reputation:
0
(01-14-2021, 10:22 AM)captain-sensible Wrote: i can only see what you have posted but index method is missing a curly brace, above that it looks un complete could be:
Code: public function index()
{
$model = new NewsModel();
$data['news'] = $model->getNews($slug);
$data = [
'news' => $model->getNews(),
'title' => 'News archive', // there is no other item so "," not needed
];
} //end of method
my code, this code from CodeIgniter4 User Guide
PHP Code: <?php namespace App\Controllers;
use App\Models\NewsModel; use CodeIgniter\Controller;
class News extends Controller { public function index() { $model = new NewsModel();
$data['news'] = $model->getNews(); }
public function view($slug = null) { $model = new NewsModel();
$data['news'] = $model->getNews($slug); } }
public function index() { $model = new NewsModel();
$data = [ 'news' => $model->getNews(), 'title' => 'News archive', ];
echo view('templates/header', $data); echo view('news/overview', $data); echo view('templates/footer', $data); }
(01-14-2021, 10:50 AM)vojkoz Wrote: (01-14-2021, 10:22 AM)captain-sensible Wrote: i can only see what you have posted but index method is missing a curly brace, above that it looks un complete could be:
Code: public function index()
{
$model = new NewsModel();
$data['news'] = $model->getNews($slug);
$data = [
'news' => $model->getNews(),
'title' => 'News archive', // there is no other item so "," not needed
];
} //end of method
my code, this code from CodeIgniter4 User Guide
PHP Code: <?php namespace App\Controllers;
use App\Models\NewsModel; use CodeIgniter\Controller;
class News extends Controller { public function index() { $model = new NewsModel();
$data['news'] = $model->getNews(); }
public function view($slug = null) { $model = new NewsModel();
$data['news'] = $model->getNews($slug); } }
public function index() { $model = new NewsModel();
$data = [ 'news' => $model->getNews(), 'title' => 'News archive', ];
echo view('templates/header', $data); echo view('news/overview', $data); echo view('templates/footer', $data); }
now you are confusing me ; two methods both called Index ? you can't have that
Arch Book CodeIgniter4 on Apache(pages 92-114)
|