php意外文件结尾的原因,解析错误:语法错误,文件结尾意外,但没有错误[关闭]...

博客内容涉及一个WordPress主题的index.php文件中出现的PHP解析错误。作者遇到的问题是代码在运行时显示语法错误,特别是在第31行。解决方案包括检查PHP版本(这里是5.4.3)并启用短标签支持,或者修改代码以使用完整PHP标签。提供的修复代码示例中,主要变化在于用`<?php`替换`<?`来避免解析错误。
摘要由CSDN通过智能技术生成

这个问题不太可能对将来的访客有所帮助;它仅与较小的地理区域, 特定的时间段或极为狭窄的情况(通常不适用于Internet的全球受众)有关。要获得使该问题更广泛适用的帮助, 请访问帮助中心。

6年前关闭。

这是我的一个wordpress主题的index.php的php代码:

$i=1;

while(have_posts() && i < 7):the_post();

$tumbUrl = '';

if(has_post_thumbnail())

{

$tumbUrl = wp_get_attachment_url( get_post_thumbnail_id($post->ID) );

}

if(i < 4):

?>

style="background-image:<?echo $tumbUrl; ?>"<?endif ;?>>

else:

?>

style="background-image:<?echo $tumbUrl; ?>"<?endif ;?>>

endif;

endwhile;

?>

当我要运行它时, 出现错误, 提示解析错误:语法错误, 第31行的C:\ wamp \ www \ wordpress \ wp-content \ themes \ Odatis \ index.php中的文件意外结束, 但是我无法找不到任何错误。

有谁能够帮助我?

(我的PHP版本是5.4.3)

#1

非常简单。你使用简短的开放标签。

在你的php.ini中启用短打标签, 或使用完整的php标签, 例如在新的PHP版本中

http://www.php.net/manual/zh/ini.core.php#ini.short-open-tag

#2

这是修改后的工作代码…

$i=1;

while(have_posts() && i < 7):the_post();

$tumbUrl = '';

if(has_post_thumbnail())

{

$tumbUrl = wp_get_attachment_url( get_post_thumbnail_id($post->ID) );

}

if(i < 4):

?>

style="background-image:<?php echo $tumbUrl; ?>"<?php endif; ?>>

else:

?>

style="background-image:<?php echo $tumbUrl; ?>"<?php endif; ?>>

endif;

endwhile;

?>

Note: Make sure the ending mark(;) are there and also the space as required.

#3

尝试将所有替换为。或者, 如果PHP <5.4, 则需要在php.ini中启用short open标签。

aww no:中缺少分号

其中之一应该解决它, 否则对不起:/

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值