这个问题不太可能对将来的访客有所帮助;它仅与较小的地理区域, 特定的时间段或极为狭窄的情况(通常不适用于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):
?>
else:
?>
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):
?>
else:
?>
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:中缺少分号
其中之一应该解决它, 否则对不起:/