解析错误:语法错误,文件意外结束但没有错误 [英] Parse error: syntax error, unexpected end of file but there is no error

查看:37
本文介绍了解析错误:语法错误,文件意外结束但没有错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

<?php$i=1;while(have_posts() && i <7):the_post();$tumbUrl = '';如果(has_post_thumbnail()){$tumbUrl = wp_get_attachment_url(get_post_thumbnail_id($post->ID));}如果(我<4):?><div id="row1"><div id="tile<?echo $i?>"类=瓷砖"><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 id="row2"><div id="tile<?echo $i?>"类=瓷砖"><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>

<?万一;终了;?></节>

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

有人可以帮我吗?

(我的 PHP 版本是 5.4.3)

解决方案

很简单.你使用短的开放标签.

在您的 php.ini 中启用短的开放标签或使用完整的 php 标签,如 <?php 在较新的 PHP 版本中默认禁用.但是你不应该在你的项目中使用简短的语法,如果你共享你的代码,这可能会导致问题.

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

This is my php code of index.php of a wordpress theme:

<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>

and when I want to run it I get the error saying that Parse error: syntax error, unexpected end of file in C:\wamp\www\wordpress\wp-content\themes\Odatis\index.php on line 31 but I cann't find any error.

Can anybody help me?

(my PHP version is 5.4.3)

解决方案

Its very simple. You use short open tags <?.

Enable the short open tags in your php.ini or use the complete php tags like <?php in newer PHP-Versions its disabled by default. But you shouldn't use the short syntax in your projects that can cause Problems if you share your code.

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

这篇关于解析错误:语法错误,文件意外结束但没有错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆