我以前遇到过这个问题,但我不记得如何解决它。我已经创建了一个简单的骨架(不能再简单了)控制器,我只是想向浏览器回显一些东西,我收到了这条消息:
Fatal error: Uncaught exception 'Zend_Session_Exception' with message 'Session must be started before any output has been sent to the browser ...
这是我的整个控制器。它显示“成功”,但也显示错误消息。如何使该错误消息静音,以便我可以简单地将某些内容回显到浏览器?
<?php
class CacheController extends Zend_Controller_Action
{
public function clearAction()
{
$this->_helper->layout->disableLayout();
$this->_helper->viewRenderer->setNoRender();
try {
$result = Model_Cache::emptyCache(array('foobar'=>1));
if ($result['status'] == true) {
echo 'Success';
} else {
echo 'Error: ' . $result['message'];
}
} catch (Exception $e) {
echo 'Error: ' . $e->getMessage();
}
}
}