【问题标题】:Parse error: syntax error, unexpected end of file - PHP 5解析错误:语法错误,文件意外结束 - PHP 5
【发布时间】:2013-01-23 19:10:08
【问题描述】:

我已经调试了我的索引文件并过滤掉了我的代码。事实证明,如果我使用以下代码,该站点会返回“意外的文件结尾”错误。如果我删除它,该站点将显示没有错误。所以我不确定我是否遗漏了任何语法代码或是否有错字。

 <?php

 // The Query
 query_posts( 'cat=9614&posts_per_page=5&tag=review' );

 // The Loop
 while ( have_posts() ) : the_post();
 ?>
 <li>
 <a href="<?php the_permalink(); ?>"><?php the_title(); ?></a>
 </li>
 <?
 endwhile;

 // Reset Query
 wp_reset_query();

 ?>

【问题讨论】:

    标签: wordpress parsing syntax


    【解决方案1】:

    使用&lt;?php 而不是&lt;?

    <?php
    
     // The Query
     query_posts( 'cat=9614&posts_per_page=5&tag=review' );
    
     // The Loop
     while ( have_posts() ) : the_post();
     ?>
     <li>
     <a href="<?php the_permalink(); ?>"><?php the_title(); ?></a>
     </li>
     <?php // error is here
     endwhile;
    
     // Reset Query
     wp_reset_query();
    
     ?>
    

    【讨论】:

    • 谢谢老兄!我的代码错误中有 85-90% 是小/次要/隐藏错误。网站现已使用修改后的代码备份。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2017-06-25
    • 1970-01-01
    • 2012-11-08
    • 1970-01-01
    • 2016-03-07
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多