解析错误:语法错误,文件意外结束但没有错误

ahm*_*iee 0 php wordpress wordpress-theming

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

<section id="content">
    <?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):
    ?>
    <div id="row1">
        <div id="tile<?echo $i?>" class="tile">
            <div id="img<?echo $i?>" class="tileimage"<?if($tumbUrl != ''):?> style="background-image:<?echo $tumbUrl; ?>"<?endif;?>></div>
            <div id="text<?echo $i?>" class="tiletext"><a href="<?php the_permalink() ?>" rel="bookmark" title="<?php the_title(); ?>"><?php the_title(); ?></a></div>
        </div>
    </div>
    <?
        else:
    ?>
    <div id="row2">
        <div id="tile<?echo $i?>" class="tile">
            <div id="img<?echo $i?>" class="tileimage"<?if($tumbUrl != ''):?> style="background-image:<?echo $tumbUrl; ?>"<?endif;?>></div>
            <div id="text<?echo $i?>" class="tiletext"><a href="<?php the_permalink() ?>" rel="bookmark" title="<?php the_title(); ?>"><?php the_title(); ?></a></div>
        </div>
    </div>
    <?
        endif;
        endwhile;
    ?>
</section>
Run Code Online (Sandbox Code Playgroud)

当我想运行它时,我得到错误说,Parse error: syntax error, unexpected end of file in C:\wamp\www\wordpress\wp-content\themes\Odatis\index.php on line 31但我找不到任何错误.

有谁能够帮我?

(我的PHP版本是5.4.3)

Ren*_*hle 13

它非常简单.您使用短开放标签<?.

php.ini中启用短打开标签,或者使用完整的php标签,例如<?php默认情况下禁用的较新的PHP-Versions.但是,如果共享代码,则不应在项目中使用可能导致问题的短语法.

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