Jquery中文网 www.jquerycn.cn
Jquery中文网 >  脚本编程  >  php  >  正文 php提示Parse error: syntax error, unexpected T_ENDWHILE in

php提示Parse error: syntax error, unexpected T_ENDWHILE in

发布时间:2018-10-22   编辑:www.jquerycn.cn
jquery中文网为您提供php提示Parse error: syntax error, unexpected T,ENDWHILE in等资源,欢迎您收藏本站,我们将为您提供最新的php提示Parse error: syntax error, unexpected T,ENDWHILE in资源
在写一个简单的程序时碰到Parse error: syntax error, unexpected T_ENDWHILE in www.111cn.net .php文件了,下面我给大家分析一下原因与解决方法。

问题现象:

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

2、同一站点部分页面显示正常(例如<?php phpinfo();?>),但打开部分页面时,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,可以禁用此选项以便于嵌入使用 <?xml ?>。否则还可以通过 PHP 来输出,例如:<?php echo '<?xml version="1.0"'; ?>。如果禁用了,必须使用 PHP 代码开始标志的完整形式(<?php ?>)。

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

解决方案:

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

相关知识:PHP短标签short_open_tag

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

 

您可能感兴趣的文章:
PHP Parse Error: syntax error, unexpected $end 错误解决办法
Parse Error: syntax error, unexpected $end 错误的解决方法
php syntax error, unexpected $end 错误怎么解决
php异常:Parse error: syntax error, unexpected eval()'d code error
php提示Parse error: syntax error, unexpected T_ENDWHILE in
PHP Parse error: syntax error, unexpected T_ENCAPSED_AND_WHITESPACE
Parse error: syntax error, unexpected T_LNUMBER
Parse Error: syntax error, unexpected $end 错误
php异常parse error: syntax error, unexpected t_var错误怎么解决
PHP Parse Error: syntax error, unexpected $end 错误的解决办法

[关闭]