2013-10-19 39 views
0

發送了頭我有這樣的已知問題:消息:無法修改標題信息 - 已經

這是我的控制器:

<?php 
ob_start(); 
if (! defined('BASEPATH')) exit('No direct script access allowed'); 
class AddScore extends CI_Controller 
{ 
    //Constructor 
     function __construct() { 
      parent::__construct(); 
      $this->load->helper ('url'); 
      $this->load->helper ('form'); 

     } 


     function AddToDatabase() 
     { 
      $userName=$_GET['userName']; 
      $userID=$_GET['userID']; 
      $score=$_GET['score']; 
      $this->load->model('module/ProductsModel'); 
      $this->UserScoresModule->AddUserScore($userID,$userName,$score); 
      // $data=array('ID' => $_GET['ID'], 'Name' => $_GET['Name']); 
      // $this->load->view ('SupplierAllProductsView',$data); 
     } 

} 

在這裏#1後一個人建議使用ob_start();,所以我將它添加到我的代碼中,但問題依然存在。

A PHP Error was encountered 

Severity: Warning 

Message: Cannot modify header information - headers already sent by (output started at /hermes/bosweb25a/b500/ipg.spaghetticodestudioc/TDDD27/application/controllers/AddScore.php:1) 

Filename: core/Common.php 

Line Number: 438 

任何想法我失蹤了?

+1

使用'ob_start'會掩蓋問題而不是解決問題。相反,在文件的開始處查看「AddScore.php」 - 你的'<?php'開始標籤之前可能有一個回車符,空格或製表符。如果您發佈的文件是同一個文件,則是造成問題的空格字符。 – halfer

回答

1

您至少在發佈的代碼中有<?php之前的空格。

服務器將HTML內容的空格發送給客戶端,即輸出。它會在發送標題之前自動添加標題,因此「標題已經發送」。