Heim  >  Artikel  >  Backend-Entwicklung  >  php提示Parse error: syntax error, unexpected T_ENDWHILE in_PHP教程

php提示Parse error: syntax error, unexpected T_ENDWHILE in_PHP教程

WBOY
WBOYOriginal
2016-07-13 10:43:191610Durchsuche

在写一个简单的程序时碰到Parse error: syntax error, unexpected T_ENDWHILE in www.bKjia.c0m .php文件了,下面我给大家分析一下原因与解决方法。

问题现象:

1、同样的代码,在某些机器上运行正常,但在特定机器上运行报错。

2、同一站点部分页面显示正常(例如),但打开部分页面时,phpxx_errors.log或者页面显示错误提示“Parse error: syntax error, unexpected T_ENDWHILE in xx.php on line xx”。

错误原因:

该错误有可能是因为编写PHP脚本时丢失一个花括号(“}”),但更常见的原因是php.ini文件中short_open_tag值为Off导致的。

决定是否允许使用 PHP 代码开始标志的缩写形式( ?>)。如果要和 XML 结合使用 PHP,可以禁用此选项以便于嵌入使用 。否则还可以通过 PHP 来输出,例如:。如果禁用了,必须使用 PHP 代码开始标志的完整形式()。

Note: 本指令也会影响到缩写形式 = ,它和 echo 等价。使用此缩写需要设置 short_open_tag 的值为 On。不推荐使用短标签,使用才是规范的方法,但因为这种短标签使用的时间比较长(历史原因),为兼容老代码,这种特性才被保存了下来。

解决方案:

将php.ini文件中short_open_tag值设置为On。

相关知识:PHP短标签short_open_tag

名字 默认 可修改范围 更新日志
short_open_tag "1" PHP_INI_ALL 在 PHP 4.0.0 时是 PHP_INI_ALL。 在 PHP
asp_tags "0" PHP_INI_PERDIR 在 PHP 4.0.0 时是 PHP_INI_ALL。
precision "14" PHP_INI_ALL  
serialize_precision "17" PHP_INI_ALL 从 PHP 4.3.2 起可用。在 PHP 5.3.5以前,默认值为 100
y2k_compliance "1" PHP_INI_ALL 在 PHP 5.4.0 中移除该选项。
allow_call_time_pass_reference "1" PHP_INI_PERDIR 在 PHP 4.0.0 时是 PHP_INI_ALL。 在 PHP 5.4.0 中移除该选项。
disable_functions "" php.ini only 从 PHP 4.0.1 起可用。
disable_classes "" php.ini only 从 PHP 4.3.2 起可用。
exit_on_timeout "" PHP_INI_ALL 从 PHP 5.3.0 起可用。
expose_php "1" php.ini only  
zend.multibyte "0" PHP_INI_ALL 从 PHP 5.4.0 起可用
zend.script_encoding NULL PHP_INI_ALL 从 PHP 5.4.0 起可用
zend.signal_check "0" PHP_INI_SYSTEM 从 PHP 5.4.0 起可用
zend.ze1_compatibility_mode "0" PHP_INI_ALL 从 PHP 5.0.0起可用。 在 PHP 5.3.0 中移除该选项
detect_unicode "1" PHP_INI_ALL 从 PHP 5.1.0起可用。 本过时特性肯定会在未来被移除

 

www.bkjia.comtruehttp://www.bkjia.com/PHPjc/633178.htmlTechArticle在写一个简单的程序时碰到Parse error: syntax error, unexpected T_ENDWHILE in www.111cn.net .php文件了,下面我给大家分析一下原因与解决方法。 问题现象...
Stellungnahme:
Der Inhalt dieses Artikels wird freiwillig von Internetnutzern beigesteuert und das Urheberrecht liegt beim ursprünglichen Autor. Diese Website übernimmt keine entsprechende rechtliche Verantwortung. Wenn Sie Inhalte finden, bei denen der Verdacht eines Plagiats oder einer Rechtsverletzung besteht, wenden Sie sich bitte an admin@php.cn