Php 分析错误:语法错误,wp get_页脚上意外出现$end
我开始建立一个模板和Php 分析错误:语法错误,wp get_页脚上意外出现$end,php,wordpress,php-parse-error,Php,Wordpress,Php Parse Error,我开始建立一个模板和 <?php get_header(); ?> <div id="box-posts"> <?php if (have_posts()) : ?> <?php while (have_posts()) : the_post(); ?> </div> </div> <?php get_footer(); ?> 这是index.php,很简单
<?php get_header(); ?>
<div id="box-posts">
<?php if (have_posts()) : ?>
<?php while (have_posts()) : the_post(); ?>
</div>
</div>
<?php
get_footer();
?>
这是index.php,很简单
<div id="footer">
<br />
Copyright (C)
<br /><br />
</div>
</center>
</body>
</html>
这是footer.php
我真的看不出这里有什么错误,但我得到了解析错误:语法错误,意外的$end您忘记了endwhile;和endif;声明。需要一个特定的xend;声明
从手册中引用:
PHP为它的一些控制结构提供了另一种语法;即if、while、for、foreach和switch。在每种情况下,备用语法的基本形式是将开始大括号更改为冒号:并将结束大括号更改为endif;,(完);;,endfor;,endforeach;,或结束开关;,分别
特别是:
if ():
...
endif;
及
使用此选项关闭endif和ifs
必须为if&while添加add终止语句-即为if&endwhile添加endif语句
希望这有帮助 是,但不是解析错误的原因。@Polygenme是错误之一。那么为什么dowvoteI没有投反对票,但这并不是我为什么会得到这个解析错误的答案。@Polygome和Jeffrey现在很好不,这是错误的。唯一的原因是我有一个未关闭的标题。不过还是要谢谢你。哦,那是真的。很抱歉,这真是个愚蠢的问题。谢谢你的快速回复。-1从我这边开始,因为这个问题没有显示任何研究成果;这是不清楚或没有用处。我也会在它关闭后投票删除它。
while ():
...
endwhile;
<?php get_header();?>
<div id="box-posts">
<?php if (have_posts()): ?>
<?php while (have_posts()): the_post(); ?>
<?php endwhile; ?>
<?php else: ?>
<p>sorry no results</p>
<?php endif; ?>
</div>
</div>
<?php get_footer(); ?>