php网站搬家引起的”syntax error unexpected $end”解决办法

由于美国服务器访问速度太慢,今天把wordpress程序迁移到韩国的win服务器,在iis7下报错。于是在wp-config.php中打开调试发现如下错误:

Parse error: syntax error, unexpected $end in ……

出错的位置在文件的最后一行,”?>”,网上查说是php语言使用不规范引起的,有的地方开头使用”<?php”,有的地方用”<?”,造成匹配问题。

后来在iis7的php manager插件中编辑php配置就解决了,原因可能是php.ini的默认配置不支持一些wordpress的插件吧!可以在图形界面下修改,也可以找到该文件手动修改。

网上查到相同的问题,并附上原因,摘抄如下:

报错的原因是:集成安装环境包默认的情况下不支持 PHP 短标签
解决办法:打开 php.ini ,找到 short_open_tag = Off 这一行,将 Off 修改为 On,保存退出,重启 Apache 就可以了。

详细的错误分析:

In PHP 5, the following error may appears as an error entry in Apache error log or simply displays on PHP web page, even if calling to php scripts with php_info() works perfectly and successfully returns information on PHP configurations:
Parse Error: syntax error, unexpected $end in ….. scripts.php on line …
The error may caused by a missing curly bracket in PHP script coding. Beside, it may also caused by error in PHP coding in class definition, as in PHP, a class definition cannot be broke up and distributed into multiple files, or into multiple PHP blocks, unless the break is within a method declaration.
But more commonly, the error is often caused by the use of Short Open tags in PHP, To use short open tags, it must be enabled in PHP.INI. Search for short_open_tag in PHP.INI, and change the value to On. The line should look line:
short_open_tag = On

发表评论

电子邮件地址不会被公开。 必填项已用*标注

Time limit is exhausted. Please reload CAPTCHA.