Выскакивает ошибка syntax error, unexpected endforeach (t_endforeach), как исправить?

0

https://yadi.sk/i/feNp6SuCcCmbnA

файл index.pxp

<h1>Все новости</h1>

<?php foreach ($news as $key => $value); ?>
<h2> <?php echo $value['title']; ?> </h2>
<?php endforeach ?>

Файл News.php

<?php

defined('BASEPATH') OR exit('No direc script access allowed');

class News extends CI_Controller {

public function __construct() {
parent::__construct();
$this->load->model('news_model');
}

public function index() {
$data['title'] = "Все новости";
$data['news'] = $this->news_model->getNews();

$this->load->view('templates/header', $data);
$this->load->view('news/index', $data);
$this->load->view('templates/footer');

}


}
codeigniter

2 ответов

1

У тебя ошибка в синтаксисе php. Ты после foreach ставишь точку с запятой:

<?php foreach ($news as $key => $value); ?>

А нужно ставить двоеточие в конце:

<?php foreach ($news as $key => $value): ?>
0

Благодарю)))

Sign up or Log in to write an answer