代码点火器中存在未定义的变量问题


Undefined variable issue in codeigniter

我正在尝试使用php从Mysql创建一个excel文件。我找到了这个链接:http://forums.digitalpoint.com/showthread.php?t=60681并使用了他的密码。然而,它产生了如下错误:

A PHP Error was encountered     
Severity: Notice        
Message: Undefined variable: header     
Filename: controllers/export_database.php       
Line Number: 26 

我在控制器中的代码:

public function export ()
    {
$line1="ID'tProduct'tColor'tSales't";
$line2="1'tPrinter'tGrey't13't";
$line3="2'tCD'tBlue't15't";
$line4="3'tDVD'tRed't7't";
$line5="4'tMonitor'tGreen't4't";
$line6="5'tTelephone'tBlack't2't";
$data="$line1'n$line2'n$line3'n$line4'n$line5'n$line6'n";
header("Content-type: application/x-msdownload"); 
header("Content-Disposition: attachment; filename=extraction.xls"); 
header("Pragma: no-cache"); 
header("Expires: 0"); 
print "$header'n$data"; //line 26
   }
}

我不知道为什么头是一个未定义的变量。有什么想法吗?谢谢你的帮助。

header()函数将数据推送到浏览器。它没有创建$header变量,因此出现了错误。

移除$header