2012-03-16 64 views
-6

可能重複:
「Warning: Cannot modify header information - headers already sent by」 error
Headers already sent by PHP警告:不能更改頭informati上 - 標題已經發出已

我有一個警告,它指出:

Warning: Cannot modify header information - headers already sent by (output started at C:\xampp\htdocs\projects\wesm\intranet\plugins\company_calendar\calendarpdf.php:90) in C:\xampp\htdocs\projects\wesm\intranet\plugins\company_calendar\mpdf\mpdf.php on line 7236 

Warning: Cannot modify header information - headers already sent by (output started at C:\xampp\htdocs\projects\wesm\intranet\plugins\company_calendar\calendarpdf.php:90) in C:\xampp\htdocs\projects\wesm\intranet\plugins\company_calendar\mpdf\mpdf.php on line 1827 
mPDF error: Some data has already been output to browser, can't send PDF file 

你能給我一些建議擺脫這些警告的..

下面是我的一些代碼:

<?php 

include "admin/include/connect.php"; 
include "include/calendarFunction.php"; 
$function = new calendarFunction(); 
$cMonth  = $_GET['cMonth']; 
$cYear  = $_GET['cYear']; 

$htmldata = $function->calendarPDF($cMonth, $cYear); 

$currString = $htmldata; 
$stringtoDelete = ''; 
$newCurrString = str_replace($stringtoDelete, " ", $currString); 
$html = $newCurrString ; 
include("mpdf/mpdf.php"); 

$mpdf=new mPDF(); 
$mpdf->AddPage('L'); 

$mpdf->WriteHTML($html); 
$mpdf->Output('calendar.pdf','I'); 
exit; 

?> 
+0

請添加您的代碼爲妥善解決 – 2012-03-16 06:36:45

+0

這個錯誤通常是當您迴應某些內容或任何不需要的換行符或空格位於文件頂部時出現。 – Ben 2012-03-16 06:39:38

回答

3

請也許有些空間頭功能或東西之前檢查有"echo"頭函數被調用之前在你的頁面。

4

如果你在標題前使用echo,你會得到這個錯誤。

例如:

<?php 
    echo "Some String"; 
    header("location:redirect.php"); 
?> 

您需要的文件在任何事情之前發送頭包括PHP之外HTML

<?php 
    header("location:redirect.php"); 
    echo "Some String"; 
?> 
相關問題