如何修复Zend中的"无法发送标头;已发送的标头"?

mym*_*and 12 php zend-framework

可能重复:
PHP已发送的标头

我是zend的新手.我尝试使用zend创建包含两个字段的简单表单.当我点击提交按钮时出现以下错误,

Fatal error: Uncaught exception 'Zend_Controller_Response_Exception' with message 'Cannot send headers; headers already sent in D:\xampp\htdocs\study\quickstart\application\controllers\EmployeeController.php, line 35' in D:\xampp\php\PEAR\Zend\Controller\Response\Abstract.php:282 Stack trace: #0 D:\xampp\php\PEAR\Zend\Controller\Response\Abstract.php(300): Zend_Controller_Response_Abstract->canSendHeaders(true) #1 D:\xampp\php\PEAR\Zend\Controller\Response\Abstract.php(727): Zend_Controller_Response_Abstract->sendHeaders() #2 D:\xampp\php\PEAR\Zend\Controller\Front.php(984): Zend_Controller_Response_Abstract->sendResponse() #3 D:\xampp\php\PEAR\Zend\Application\Bootstrap\Bootstrap.php(77): Zend_Controller_Front->dispatch() #4 D:\xampp\php\PEAR\Zend\Application.php(358): Zend_Application_Bootstrap_Bootstrap->run() #5 D:\xampp\htdocs\study\quickstart\public\index.php(25): Zend_Application->run() #6 {main} thrown in D:\xampp\php\PEAR\Zend\Controller\Response\Abstract.php  on line 282
Run Code Online (Sandbox Code Playgroud)

我检查了以下链接, zend header已经发送问题了

我删除了空格并在所有文件中给出了密切标记,但我仍然得到同样的错误.

如何解决这个错误?

以下显示了EmployeeController.php:

<?php 
class EmployeeController extends Zend_Controller_Action
{
    public function init()
    {

    }
    public function indexAction()
    {

      $form = new Default_Form_Empdetails();
       $this->view->form = $form;
        $request = $this->getRequest();
          $formData = $request->getPost();
        if ($request->isPost()) {
            if ($form->isValid($request->getPost())) {  
                $empName = $form->getValue('empName');
                $empAddress = $form->getValue('empAddress');
                $emp = new Default_Model_DBTable_Employee();
                $emp->addAlbum($empName, $empAddress);
              $this->_helper->redirector('index');
            } else {
                $form->populate($formData);
            }
        }

    }
}
?>
Run Code Online (Sandbox Code Playgroud)

请帮助我

Nav*_*eed 24

可能是因为php ?>在某些文件中关闭了tag()后出现了额外的空格.

另读这篇文章:

PHP开发:为什么重定向不起作用(标头已经发送)

  • 任何HTML输出,包括DOCTYPE声明或任何HTML标记,包括页面的头部
  • 在打开页面的PHP标记之前或包含文件的PHP标记之外的额外空格
  • 在调用header()或session_start()之前使用print()或echo
  • 使用virtual()包含文件
  • 使用页面开头的字节顺序标记(BOM)

例如:

在此输入图像描述