解析错误:语法错误,意外T_ENDWHILE

时间:2012-06-06 21:46:15

标签: php

<?php get_header(); ?>
<div id="content">

<?php if (have_posts()): ?>

    <?php $i=0;?>
    <?php while (have_posts()) : the_post(); ?>
    <?php $i++;?>
    <div class="cols"<? if($i%3==0) echo ' style="margin-right:0"';?>>
        <div class="post" id="post-<?php the_ID(); ?>">
            <?php $thumb=get_post_meta($post->ID, 'image', true); ?>
            <a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>">
            <?php if($thumb!=''){
            $thumb = str_replace(get_bloginfo('url').'/','',$thumb);
            ?>
            <img src="<?php bloginfo('template_url');?>/thumb.php?src=<?=$thumb;?>&w=183&h=140&zc=1" class="thumb" alt="<?php the_title(); ?>" />
            <? } else { ?>
            <img src="<?php bloginfo('template_url'); ?>/images/pic.jpg" alt="" class="thumb" />
            <? } ?>
            </a>

            <h2 class="title"><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><?php echo cut_string(get_the_title(),30,'...'); ?></a></h2>
            <p><?php echo cut_string(get_the_content(),60,'...'); ?></p>
            <p class="meta">
            <?php if(function_exists('the_views')) { ?>
            <span class="views"><?php the_views(); ?></span> <?php } ?>
            <?php comments_popup_link('No Comments', '1 Comment', '% Comments', 'comments'); ?>
            </p>
            <p><?php if(function_exists('the_ratings')) { the_ratings(); } ?> </p>

        </div></div>

    <?php endwhile; ?>
    <div class="clearfix"></div>
    <div class="page_navi"><?php page_navi();?></div>

<?php else: ?>

    <div class="post">
        <h2 class="title">Not Found</h2>
    </div>

<?php endif; ?>
</div>

<!-- end content -->

<?php get_sidebar(); ?>
<?php get_footer(); ?>

解析错误:

  

语法错误,第36行/home/fakecsc1/domains/jocuri2k.com/public_html/wp-content/themes/Games/index.php中的意外T_ENDWHILE

此代码有什么问题?我该如何解决?

1 个答案:

答案 0 :(得分:12)

问题是您在<?处使用<?php代替 <? } else { ?> <img src="<?php bloginfo('template_url'); ?>/images/pic.jpg" alt="" class="thumb" /> <? } ?> </a>

endwhile

如果您的服务器没有将这些解释为PHP,那么php会在看到关闭标记之前看到<?php。将它们更改为<?而不是{{1}}。

相关问题