您的位置:首页 > 编程语言 > PHP开发

php环境变化引起的"syntax error unexpected $end"

2012-02-23 16:17 507 查看
今天修改php配置环境,将php.ini-develop 设为默认的php.ini,之后访问测试web的后台,报错:

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

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

后来将新的php.ini配置文件删除之后,重启nginx,web服务器恢复正常。

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

报错的原因是:集成安装环境包默认的情况下不支持 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

本文出自 “三足乌工作室” 博客,请务必保留此出处http://webteam.blog.51cto.com/863355/787895
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐