2011-06-21 34 views
10

thể trùng lặp:
Headers already sent by PHPCách khắc phục "Không thể gửi tiêu đề; tiêu đề đã được gửi" trong Zend?

Tôi mới vào zend.I cố gắng để tạo ra hình thức đơn giản có hai lĩnh vực sử dụng zend. Khi tôi bấm nút gửi đã nhận lỗi sau đây,

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 

Tôi đã kiểm tra đường dẫn sau, zend header already send problem

tôi loại bỏ không gian màu trắng và tặng thẻ chặt chẽ trong tất cả các file, nhưng tôi vẫn đang nhận được cùng một lỗi.

Cách khắc phục lỗi này?

chương trình Sau 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); 
      } 
     } 

    } 
} 
?> 

Vui lòng giúp tôi

+0

Có gì trong EmployeeController.php, dòng 35? –

+1

Xóa các khoảng trắng sau khi đóng các thẻ php ('?>') Trong tất cả các tệp .. – NAVEED

+0

@NAVEED Có xóa nó hoạt động. Cảm ơn nhưng trước khi tôi xóa không gian màu trắng ở trên điểm bắt đầu của thẻ php – mymotherland

Trả lời

23

Nó có thể là do không gian màu trắng thêm sau thẻ php bế mạc (?>) trong một số tập tin.

Cũng đọc bài viết:

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

  • Bất kỳ đầu ra HTML, bao gồm việc khai báo DOCTYPE hoặc bất kỳ thẻ HTML, bao gồm người đứng đầu của trang
  • tắm trắng trước ngày khai mạc Thẻ PHP của trang hoặc bên ngoài các thẻ PHP của tệp bao gồm
  • Sử dụng print() hoặc echo trước khi ca tiêu đề lling() hoặc session_start()
  • Sử dụng ảo() để bao gồm các file
  • Sử dụng dấu byte đặt hàng (BOM) vào đầu của một trang

Ví dụ:

enter image description here

Các vấn đề liên quan