2011-06-21 34 views
10

可能性の重複:
Headers already sent by PHPZendで「ヘッダを送信できません:すでに送信されたヘッダ」を修正するには?

私はzend.Iに新しいですがZendのを使用して2つのフィールドを持つ簡単なフォームを作成しようとしました。私は、ボタンには、次のエラーを得た提出クリックすると、

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); 
      } 
     } 

    } 
} 
?> 

親切にそれはPHPは、いくつかのファイルにタグ(?>)を閉じた後ので、余分な空白のものとすることができる私に

+0

35行目のEmployeeController.phpには何がありますか? –

+1

すべてのファイルでPHP終了タグ( '?>')の後に空白を削除します。 – NAVEED

+0

@NAVEEDはい削除されました。ありがとう、私はPHPのタグ – mymotherland

答えて

23

を助けます。

また、この記事を読む:

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

  • DOCTYPE宣言または任意のHTMLタグを含む任意のHTML出力を、開口部の前にページの先頭
  • エクストラ空白を含む をページのPHPタグ、またはその外にある インクルードファイルのPHPタグ
  • caの前にprint()またはechoを使用する

    :たとえばページ

の先頭にバイトオーダーマーク(BOM)を使用してファイル

  • を含める)(仮想を使用してllingヘッダ()またはのsession_start()
  • enter image description here

  • 関連する問題