我的Codeigniter有错误:
遇到PHP错误
Severity: Warning
Message: Cannot modify header information - headers already sent by (output started at C:\PROJECT_TEMP\evaluasiTIK_HG\application\modules\rss\controllers\feed.php:25)
Filename: controllers/feed.php
Line Number: 21
feed.php:
<?php
class Feed extends Controller
{
function Feed()
{
parent::Controller();
$this->load->model('posts_model', '', TRUE);
$this->load->helper('xml');
}
function index()
{
$data['encoding'] = 'utf-8';
$data['feed_name'] = 'DerekAllard.com';
$data['feed_url'] = 'http://www.syslog-center.net/theme/theme2/syslog.xml';
$data['page_description'] = 'Code Igniter, PHP, and the World of Web Design';
$data['page_language'] = 'en-ca';
$data['creator_email'] = 'Derek Allard is at derek at derekallard dot com';
$data['posts'] = $this->posts_model->getRecentPosts();
header("Content-Type: application/rss+xml");
view('rss/feed', $data);
}
}
?>
任何人都可以帮助我。请:)
答案 0 :(得分:0)
在&gt;后面有无关的空格,删除最后一行。
答案 1 :(得分:0)
您使用1.7.2版本的CodeIgniter吗?请修改您的代码:
查找
header("Content-Type: application/rss+xml");
view('rss/feed', $data);
替换为:
$this->output->set_header("Content-Type: application/rss+xml");
$this->load->view('rss/feed', $data));