升级到PHP7.1和M​​PDF时显示错误-在第30648行遇到一个非数字值 [英] Upgrade to PHP7.1 and MPDF show error - A non-numeric value encountered at line 30648

查看:216
本文介绍了升级到PHP7.1和M​​PDF时显示错误-在第30648行遇到一个非数字值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我长时间使用PHP 5.x和mPDF 6.x.

I'm using PHP 5.x and mPDF 6.x for long time.

这周我决定将系统升级到PHP7.1,但仍使用mPDF6.

This week I decide to upgrade system to PHP7.1 but still using mPDF6.

升级后我遇到了一些问题.

I face some problem after upgrading.

问题1 ::

控制台显示错误消息:不赞成使用与类名相同的构造方法.

Console show error message: constructer with the same name as class name is deprecate.

我遍历每个php文件并找到类,然后将构造函数替换为__construct(...)

I go through each php files and find classes, then replace constructer function with __construct(...)

问题2 ::

控制台显示错误消息::无法将属性ID分配给$ attr 我在函数MergeCSS(...)中转到文件mPDF.php.我在第三行添加新的代码行.

Console show error message:: Can not assign property ID to $attr I go to file mPDF.php in function MergeCSS(...). I add new line of code at third line.

if(empty($ attr)){$ attr = array();}

if (empty($attr)) { $attr = array();}

问题3 ::

控制台显示以下错误消息:: 在行30648处遇到非数值".

Console show error message following this:: "A non-numeric value encountered" at line 30648."

我解决这个问题的方法是:

My solution to solve this problem is just::

    使用来自MPDF7的编码,在mPDF.php文件中
  1. 替换mPDF-> ConvertSize()函数.
  1. replace mPDF->ConvertSize() function in mPDF.php file with coding from MPDF7.

通过将功能ConvertSize()替换为功能ConvertSize()和multipleFontSize();

By replace function ConvertSize() with function ConvertSize() and multiplyFontSize();

https://github.com/mpdf/mpdf/blob/development/src/SizeConverter.php

  1. 向mPDF类添加常量

const SCALE = 72/25.4;

const SCALE = 72 / 25.4;

希望为遇到此问题的人提供帮助.

Hope this help for someone who face this problem.

推荐答案

适用于需要完整的遇到非数字值"修复程序的人.使用 commit 看一下我的mpdf 6.1.3分叉的回购.

For people who want a complete "A non-numeric value encountered" fix. Take a look at my forked repo of mpdf 6.1.3 with commit.

这篇关于升级到PHP7.1和M​​PDF时显示错误-在第30648行遇到一个非数字值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆