Php 使用TCPDF时出错

Php 使用TCPDF时出错,php,laravel-4,tcpdf,Php,Laravel 4,Tcpdf,我尝试在laravel 4中使用TCPDF,当我用mysql数据填充我的表时,我遇到了这个错误,当我使用foreach循环时,它失败了,如果我删除它,它工作得很好: 类PrintController扩展BaseController{ 公共职能指数() { 返回视图::make('print.PrintView'); } 公共函数generatePDF() { $notas_detalle=NotaDetalle::all(); $pdf=$pdf=新的TCPDF(); $pdf->SetPri

我尝试在laravel 4中使用TCPDF,当我用mysql数据填充我的表时,我遇到了这个错误,当我使用foreach循环时,它失败了,如果我删除它,它工作得很好:

类PrintController扩展BaseController{
公共职能指数()
{
返回视图::make('print.PrintView');
}
公共函数generatePDF()
{
$notas_detalle=NotaDetalle::all();
$pdf=$pdf=新的TCPDF();
$pdf->SetPrintHeader(假);
$pdf->SetPrintFooter(false);
$pdf->AddPage();
$html=
'
查潘顿S.R.L

阿古斯丁·巴里奥斯1070摄氏度/胡里奥·c·佛朗哥-电信674 942华氏度
费尔南多·德拉莫拉-巴拉圭

RUC:80029658-3

普雷斯普埃斯托酒店

亚松森,2014年11月26日 Señores:Aseguradora del Este 迪雷西翁:吉尔伯托·阿兰达231 电话:021674611 Fecha:20/12/2014 康蒂达 描述 Precio con IVA Precio sin IVA '; $html.=''; //这里是错误 foreach($key=>value){ $html.=''.$value->cantidad_detalle'; $html.=''.$value->description_detalle'; $html.=''.$value->precioIVA_detalle'; $html.=''.$value->precioSinIVA_detalle'; } //错误 $html.=''; $html.= ' ' ; $pdf->writeHTML($html,true,false,true,false,”); //$pdf->Text(90140,“这是一个测试”); $filename=storage_path()。/test.pdf'; $pdf->output($filename,'I'); //返回响应::下载($filename); } }

我做错了什么?。请提供帮助。

注释中提供了解决方案。在此处提供,以防其他人遇到类似问题:

$html .= '<tr>';
$html.='';

$html.='';

需要在foreach循环中

tcpdf输出的错误是什么?可能您的$notas_detalle是空的,tcpdf不知道如何处理弹出的PHP错误,而不是您所期望的错误?这是laravel错误日志:它不是空的,因为我使用isEmpty()if($notas_detalle->isEmpty()){echo'';print_r($notas_detalle)验证它;echo“”;}否则{echo“”;echo“SIN ERROR”;echo“”;}不要忘记放置$html.=''和$html.='';在foreach循环中。是的!!那工作!!非常感谢你!!这就是问题所在!!
$html .= '<tr>';
$html .= '</tr>';