我不知道为什么,但我的pdf批次不起作用,现在我有这个错误 . 问题来自while循环中的类
谢谢
注意:OM \ Registry :: set - 订单已经注册,并且不会被强制替换在第33行的/home/www/shop/includes/OM/Registry.php中致命错误:未捕获异常:FPDF错误:某些数据有已输出,无法发送PDF文件/home/www/boutique/ext/fpdf/fpdf.php:271堆栈跟踪:#0 /home/www/boutique/ext/fpdf/fpdf.php(1063): FPDF->错误('某些数据有...')#1 /home/www/boutique/ext/fpdf/fpdf.php(999):FPDF - > _ checkoutput()#2 / home / www / boutique / admin / invoice_batch.php(570):第271行/home/www/boutique/ext/fpdf/fpdf.php中的FPDF->输出()#3
此错误与此元素有关
// Classe pdf.php
$pdf = new \FPDF();
// $pdf->SetWidths(array(30,50,30,40));
while ($QordersInfo->fetch()) {
Registry::set('Order', new OrderAdmin($QordersInfo->valueInt('orders_id')));
$order = Registry::get('Order');
...
..
}
// PDF's created no
// output the file
$pdf->Output();
如果我这样写它“完美地工作”但它只显示1张发票 .
// Classe pdf.php
$pdf = new \FPDF();
// $pdf->SetWidths(array(30,50,30,40));
while ($QordersInfo->fetch()) {
Registry::set('Order', new OrderAdmin($QordersInfo->valueInt('orders_id')));
$order = Registry::get('Order');
.....
// output the file
$pdf->Output();
}
1 回答
在不知道
Registry::set()
的情况下很难跟踪问题,但看起来该函数的第一个参数应该是唯一键 . 在您的代码中,在循环的每次迭代中,键始终为'Order'
. 第一次迭代没问题,但是在第二次迭代中,它将生成输出以给出Notice
,其中已经存在具有该键的注册表项 .$pdf->Output()
函数检查PHP代码中是否有任何输出 . 因为Notice
被发送到输出,FPDF无法开始渲染并产生FPDF错误让你知道 .要么使用唯一键(可能是订单的ID?),要么强制在每次迭代中替换注册表项 . 如果这不能让您再次进入正轨,请发布Registry类代码,以便我们深入研究问题 .