在php程序出现类似
Parse error: syntax error, unexpected end of file in xxxxxxxx on
line xx
的错误。
如果发现php的语法本身没有什么错误。就有可能是使用了短标签,例如:
<? }?>
这种问题的解决方案是:
可以在php.ini中设置short_open_tag = On
---------------------------------------------------------
short_open_tag 是什么呢?
决定是否允许使用代码开始标志的缩写形式(<? ?> )。如果要和 XML 结合使用 PHP,可以禁用此选项以便于嵌入使用<?xml ?> 。否则还可以通过php来输出,例如:<?php echo '<?xml version="1.0"'; ?> 。如果禁用了,必须使用 PHP 代码开始标志的完整形式(<?php ?> )。
注意:本指令也会影响到缩写形式 <?= ,它和 <? echo 等价。使用此缩写需要short_open_tag 的值为 On。
本文介绍了如何解决PHP程序中因使用短标签导致的Parse error: syntax error, unexpected end of file错误。文中解释了short_open_tag配置项的作用,并指导读者如何在php.ini文件中正确设置以启用或禁用短标签。
&spm=1001.2101.3001.5002&articleId=52798684&d=1&t=3&u=84ddff7584bd4ae39f9062adb99fba76)
837

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



