[英]Illegal offset type in PHP (FPDF)
I got this problem, with my PHP code. 我的PHP代码出现了这个问题。 I'm building a FPDF-script, there should add pages to the book. 我正在构建FPDF脚本,应该在书中添加页面。 Earlier in the code, the Table Of Contents is defines, and the order is saved in the class' public $pdf->order
-array. 在代码的前面,定义了目录,并将订单保存在类的公共$pdf->order
。 The script reply's with: 脚本回复的内容为:
Warning: Illegal offset type in /var/www/domain/labs/book/fpdf.php on line 573 警告:第573行的/var/www/domain/labs/book/fpdf.php中的偏移量类型非法
Here's a stump of my code. 这是我的代码的树桩。
function GetPersons(){
echo gettype($this->order);
foreach($this->order as $key => $val){
$this->MakePage("Blahblahblah");
}
}
The $pdf->order
is defined as following: $pdf->order
定义如下:
function MakeTOCChapter($cat, $lvl){
$this->SetFont('Helvetica','',12);
$q = DB::query("SELECT name, id FROM paragraphs WHERE category=%i ORDER BY name ASC", $cat);
if(DB::count()) {
foreach($q as $r) {
$this->links[$r["id"]] = $this->AddLink();
$this->Write(1,$lvl.$r["name"], $this->links[$r["id"]]);
$this->order[] = $r["id"];
$this->Ln(5);
}
}
$this->SetFont('Helvetica','B',12);
}
The error was in a hole other part of the script, that haven't throwed errors before. 该错误位于脚本其他部分的漏洞中,之前没有引发过错误。 FPDF already uses $links
, and the my script is based on a custom extension of the FPDF class. FPDF已经使用$links
,而我的脚本基于FPDF类的自定义扩展名。 So I overwrote it - but I don't know why the error didn't threw errors before. 所以我改写了它-但我不知道为什么错误以前没有抛出错误。
Anyways, it works now; 无论如何,它现在可以工作; I changed my own $pdf->links
to $pdf->mylinks
:). 我将自己的$pdf->links
更改为$pdf->mylinks
:)。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.