PHP Fpdi 错误"unexpected T_USE, expecting T_FUNCTION"



我正在尝试将两个pdf与fpdi和fpdf合并,但是我遇到了一个错误,我没有找到任何关于它的内容。我从 https://www.setasign.com/products/fpdi/demos/concatenate-fake/中获取了基本代码 我也在使用CodeIgniter。

有我的代码:

use setasignFpdiFpdi;
require_once(APPPATH. 'third_party/fpdf/fpdf.php');
require_once(APPPATH. 'third_party/fpdi/src/autoload.php');
$files = array($this->internalURL . "assets/uploadedContent/Test.pdf", $this->internalURL . "assets/uploadedContent/Test.pdf");
$pageCount = 0;

class ConcatPdf extends Fpdi
{
public $files = array();
public function setFiles($files)
{
$this->files = $files;
}
public function concat()
{
foreach($this->files AS $file) {
$pageCount = $this->setSourceFile($file);
for ($pageNo = 1; $pageNo <= $pageCount; $pageNo++) {
$pageId = $this->ImportPage($pageNo);
$s = $this->getTemplatesize($pageId);
$this->AddPage($s['orientation'], $s);
$this->useImportedPage($pageId);
}
}
}
}
$pdf = new ConcatPdf();
$pdf->setFiles($files);
$pdf->concat();
$pdf->Output('I', './assets/uploadedContent/concat.pdf');

我得到了这个错误:

解析错误:语法错误,意外T_USE,期望在第 27 行的/var/www/sites/*******/public/application/third_party/fpdi/src/Fpdi.php 中T_FUNCTION

错误来自 Fpdi 在此行的文件:

use FpdiTrait;

我不知道是来自我还是?

您使用的是过时的 PHP 版本。更新到最新版本。FPDI 2 支持 PHP 5.6 及更高版本。

相关内容

最新更新