致命错误:switch语句在mpdf.php中只能包含一个默认子句 [英] Fatal error: Switch statements may only contain one default clause in mpdf.php

查看:62
本文介绍了致命错误:switch语句在mpdf.php中只能包含一个默认子句的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用mPDF,并且与localhost正常工作.我将项目上传到实时服务器,但无法正确生成pdf.

I am using mPDF and it is working fine with localhost. I upload the project to live server and it is not generating pdf correctly.

<?php

// HTML ommited

$body = ob_get_clean();

include ("mpdf/mpdf.php");

$mpdf = new mPDF('+aCJK', 'A4', '', '', 0, 0, 0, 0, 0, 0);

$mpdf->WriteHTML($body);

$mpdf->Output('SaveToPDF.pdf', 'D');

在顶部,我放置了错误显示代码.要查看错误,出了什么问题,我遇到了以下错误.

On the top, I put the error show code. To see the error what is going wrong I have the following error.

致命错误:Switch语句中只能包含一个默认子句 /customers/d/e/a/....URL..GO..HERE/mpdf.php,第1432行

Fatal error: Switch statements may only contain one default clause in /customers/d/e/a/....URL..GO..HERE/mpdf.php on line 1432

我在Localhost上和现场直播中使用的是PHP 5.6.31版,我正在使用one.com,在那里可以切换到不同的PHP版本,并且尝试了所有版本.即5.6、7.0、7.1、7.2 beta

I am using PHP Version 5.6.31 on my Localhost and on live I am using one.com and there I can switch to different PHP versions, and I tried all. i.e. 5.6, 7.0, 7.1, 7.2 beta

我正在使用mPDF 5.7,它不是作曲家版本.我想用 我的pdf的中文字符,并且在5.7中提供了很好的支持. 这就是为什么我选择较旧的版本

I am using mPDF 5.7 and it is not composer version. I wanted to use chines character for my pdf and it good support available in 5.7. That's why I chose older version

推荐答案

旧的mpdf版本不支持PHP7,不幸的是(

Old mpdf versions don't support PHP7, unfortunately (mpdf issue). You can either:

  1. 切换到实际的mpdf版本,并对中文使用此替代方法字体;
  2. 或将实时服务器PHP更改为5.6( PHP RFC多个默认情况下语法错误);
  3. 或者自己修复mpdf源中的此切换问题(人们讨论了可能的解决方案在此hhvm问题中),您只需要删除default一条语句即可.
  1. Switch to actual mpdf version and use this workaround for chinese fonts;
  2. Or change your live server PHP to 5.6 (PHP RFC multiple default cases syntax error);
  3. Or fix this switch issue in mpdf source yourself (people discussed the possible solution in this hhvm issue), you just need to remove one of the default statements.

这篇关于致命错误:switch语句在mpdf.php中只能包含一个默认子句的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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