今天安装了Discuz之后,打开是PHP原码, 开始以为是Apache配置有问题,但是我在Discuz的目录写了简单的PHP程序,却能执行。实际上,Discuz的PHP程序是被执行了,而且上传到网站上也是好的,所以只好看Discuz原码,最后发现
include template("discuz")
模板文件里的PHP不能执行,打开之后发现所有的模板文件里的PHP标记都是<?, 而一般都是<?php, 这个可以在PHP.ini里找到这个开关short_open_tag,最后问题终于解决了。
; Allow the <? tag. Otherwise, only <?php and <script> tags are recognized.
; NOTE: Using short tags should be avoided when developing applications or
; libraries that are meant for redistribution, or deployment on PHP
; servers which are not under your control, because short tags may not
; be supported on the target server. For portable, redistributable code,
; be sure not to use short tags.
short_open_tag = On
On 就是允许短标记, Off就是禁止短标记。
本文介绍了在使用Discuz论坛程序时遇到的问题:页面显示为PHP原码而非正常页面。通过排查发现是由于PHP短标记设置导致的问题。文章详细解释了解决方案,即在PHP.ini中设置short_open_tag选项。

被折叠的 条评论
为什么被折叠?



