我对mPDF 5.6有同样的问题 . 当我使用xdebug时,我找到了这两行:
$str = @preg_replace('/\&\#([0-9]+)\;/me', "code2utf('\\1',{$lo})",$str);
$str = @preg_replace('/\&\#x([0-9a-fA-F]+)\;/me', "codeHex2utf('\\1',{$lo})",$str);
正如您所看到的那样,“@”char阻止错误输出 . 因此,如果你有php> = 7.0,你永远不会得到关于弃用的“e”修饰符的错误 . 因此,在这些行之后,所有HTML都将为NULL .
我更新了这个功能:
// mpdf/includes/functions.php
if (!function_exists('strcode2utf')) {
function strcode2utf($str,$lo=true)
{
//converts all the nnn; and hhh; in a string to Unicode
if ($lo) { $lo = 1; } else { $lo = 0; }
// Deprecated modifier "E" in preg_replace
//$str = @preg_replace('/\&\#([0-9]+)\;/me', "code2utf('\\1',{$lo})",$str); // blocked errors output!! wtf?
//$str = @preg_replace('/\&\#x([0-9a-fA-F]+)\;/me', "codeHex2utf('\\1',{$lo})",$str);
$str = preg_replace_callback('/\&\#([0-9]+)\;/m',
function($num) use ($lo) {
return code2utf($num, $lo);
}, $str);
$str = preg_replace_callback('/\&\#x([0-9a-fA-F]+)\;/m',
function($num) use ($lo) {
return codeHex2utf($num, $lo);
}, $str);
return $str;
}
}