How to make mPDF 6.1 work with PHP 7.1.5

2020-04-21 07:08发布

问题:

Developed on on a WAMP stack with PHP 5.6, then transferred to LAMP 7.1.5 Everything is working OK except for mPDF 6.1.0 which is giving the following:

Warning: A non-numeric value encountered in /var/sites/s/example.com/php_libs/vendor/mpdf/mpdf/mpdf.php on line 30648

Warning: A non-numeric value encountered in /var/sites/s/example.com/php_libs/vendor/mpdf/mpdf/mpdf.php on line 17074

Warning: A non-numeric value encountered in /var/sites/s/example.com/php_libs/vendor/mpdf/mpdf/mpdf.php on line 17075

Warning: A non-numeric value encountered in /var/sites/s/example.com/php_libs/vendor/mpdf/mpdf/mpdf.php on line 17093

I tried the solutions mentioned at Upgrade to PHP7.1 and MPDF show error - A non-numeric value encountered at line 30648 but that hasn't fixed it.

回答1:

Edit mpdf.php, line 89, replace:

$errorlevel = error_reporting($errorlevel & ~E_NOTICE);

with:

$errorlevel = error_reporting($errorlevel & ~(E_NOTICE|E_WARNING));

Reason: https://stackoverflow.com/a/42044413/8284401



标签: mpdf php-7.1