2011-06-21 95 views
10

可能重复:
Headers already sent by PHP如何解决Zend中的“无法发送头文件;头文件已发送”?

我是新来zend.I试图以创建具有使用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 

我检查下面的链接, zend header already send problem

我删除空格,并在所有文件给了密切的标签,但还是我收到同样的错误。

如何解决此错误?

以下所示为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); 
      } 
     } 

    } 
} 
?> 

请帮我

+0

EmployeeController.php第35行是什么? –

+1

在php关闭所有文件中的标签('?>')后删除空格。 – NAVEED

+0

@NAVEED是删除它的作品。谢谢,但我之前删除了以上的PHP标记 – mymotherland

回答

23

这可能是因为在某些文件PHP结束标记(?>)后多余的空白空间。

还可以阅读这篇文章:

PHP development: why redirects don't work (headers already sent)

  • 任何HTML输出,包括DOCTYPE声明或HTML标签, 包括页面开幕前
  • 多余的空格头包含文件的PHP标记
  • 使用print()或echo在ca之前灌装头()或在session_start()
  • 使用虚拟()以包括文件
  • 在页面

的开始例如使用字节顺序标记(BOM):

enter image description here

相关问题