Upgrade to PHP7.1 and MPDF show error - A non-numeric value encountered at line 30648

谁都会走 提交于 2019-12-13 12:05:21

问题


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

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

I face some problem after upgrading.

PROBLEM 1::

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

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

PROBLEM 2::

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();}

PROBLEM 3::

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

My solution to solve this problem is just::

  1. replace mPDF->ConvertSize() function in mPDF.php file with coding from MPDF7.

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

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

  1. Add constant to mPDF class

const SCALE = 72 / 25.4;

Hope this help for someone who face this problem.


回答1:


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.




回答2:


FYI: PHP7 throws a compile-time error when it encounters a switch statement with multiple default blocks. mpdf uses multiple default blocks in its switch statements.



来源:https://stackoverflow.com/questions/43994365/upgrade-to-php7-1-and-mpdf-show-error-a-non-numeric-value-encountered-at-line

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!