解决PHP报错Parse error: syntax error, unexpected end of file in的问题

今天在迁移网站的时候遇到了这个问题,所以来此分享一下解决方法。

环境

之前我一直用的宝塔面板,最近准备换换口味,所以换成了appnode。appnode虽然功能挺全的,但是我的机器用起来一卡一卡的,所以就换成了小皮面板(原PHPStudy),使用PHP7.3时一个网站出现了该问题。

问题描述

CMS是wordpress,前端是moonpro。

解决方案

这个是由于代码不规范(其实严格意义上来讲也不能算的上是不规范)造成的,我们只需开启PHP的短代码功能即可解决。这个是php.ini对此的注释:

; short_open_tag
;   Default Value: On
;   Development Value: Off
;   Production Value: Off

; This directive determines whether or not PHP will recognize code between
; <? and ?> tags as PHP source which should be processed as such. It is
; generally recommended that <?php and ?> should be used and that this feature
; should be disabled, as enabling it may result in issues when generating XML
; documents, however this remains supported for backward compatibility reasons.
; Note that this directive does not control the <?= shorthand tag, which can be
; used regardless of this directive.
; Default Value: On
; Development Value: Off
; Production Value: Off
; http://php.net/short-open-tag

其默认设置为

short_open_tag = Off

可能是小皮面板开发者的癖好吧,改成ON即可。重载PHP就可见效果。

THE END
喜欢就支持以下吧
点赞2赞赏
分享
评论 抢沙发