首页 > 解决方案 > PHP 7 上的 TCPDF 错误

问题描述

我正在使用 TCPDF 插件在 PHP 7 中生成 PDF。相同的代码在较低版本的 PHP 5 中运行良好,但是当我在 PHP 7 中运行相同的代码时,它会给出以下错误消息。

A PHP Error was encountered
Severity: 8192

Message: The each() function is deprecated. This message will be suppressed on further calls

Filename: tcpdf/tcpdf.php

Line Number: 16542

标签: phptcpdfphp-7.2

解决方案


在文件中编辑:\FPDI\fpdi.php第 567 行:

//while (list($k, $v) = each($value[1])) {

在代码中: foreach ($value[1] AS $k => $v) {

并在文件中编辑:\tcpdf\tcpdf.php第 16543 行:

//while (list($id, $name) = each($attr_array[1])) {

在代码中: foreach($attr_array[1] as $id => $name) {


推荐阅读