我以前遇到过这个问题,但我不记得如何解决它。我已经创建了一个基本的(再简单不过了) Controller ,我只是想向浏览器回显一些东西,我收到了这条消息:
Fatal error: Uncaught exception 'Zend_Session_Exception' with message 'Session must be started before any output has been sent to the browser ...
这是我的整个 Controller 。它显示“成功”,但也显示错误消息。我怎样才能使该错误消息静音,以便我可以简单地向浏览器回显一些内容?
<?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();
}
}
}
最佳答案
根据内存,此错误通常是由于非 PHP 代码在预期(和 session 初始化)之前开始输出。通常是由于不必要的 ?>
标签后出现空格或回车。这是我要检查的第一件事。
关于php - Zend_Session : Session must be started before any output has been sent to the browser,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3928597/