这是错误:
Warning (2): Cannot modify header information - headers already sent by (output started at /usr/share/php/cake/basics.php:111) [CORE/cake/libs/controller/controller.php, line 640]
$status = "Location: http://mydomain.com/blog/index"
header - [internal], line ??
Controller::header() - CORE/cake/libs/controller/controller.php, line 640
Controller::redirect() - CORE/cake/libs/controller/controller.php, line 621
PostsController::add() - APP/controllers/posts_controller.php, line 25
Object::dispatchMethod() - CORE/cake/libs/object.php, line 115
Dispatcher::_invoke() - CORE/cake/dispatcher.php, line 227
Dispatcher::dispatch() - CORE/cake/dispatcher.php, line 194
[main] - APP/webroot/index.php, line 88
这是代码posts_controller.php
:
function add() {
if (!empty($this->data)) {
$this->Post->create();
if ($this->Post->save($this->data)) {
$this->Session->setFlash(__('Post saved!!', true));
$this->redirect(array('action'=>'index')); // line 25
} else {
}
}
$tags = $this->Post->Tag->find('list');
$statuses = $this->Post->Status->find('list');
$this->set(compact('tags', 'statuses'));
}
这是第 111 行:
echo "\n<pre class=\"cake-debug\">\n";
核心蛋糕文件
debug_print_backtrace()
的输出:http: //pastebin.com/fBFrkYsPbasics.php
我已经浏览了我编辑的所有文件(而不是我刚刚烘焙的文件),并且我在 php 括号 () 之外没有任何空格。我使用了这个脚本:Find all files with Blank or WS at BOF or EOF。
我的文本编辑器设置为 UTF-8。基本上,当我注释掉第 25 行(上面标有注释)时,问题就消失了。但我应该能够使用重定向......有人能指出我正确的方向吗?
编辑:在上面的 111 处添加了行;编辑 2:添加了 debug_print_backtrace() 的输出