解析错误:语法错误,意外的文件结束 - 第59行

时间:2012-08-09 14:51:29

标签: php wordpress

在Wordpress中激活修改后的主题时会出现此错误:

解析错误:语法错误,第59行的C:\ xampp \ htdocs \ wp-content \ themes \ manifest_v1.1 \ functions.php中的文件意外结束

已修改functions.php文件,以便在发布评论时选择“主题”行。

以下是代码:

<?php
$cats=array(
1=>'Category 1',
2=>'Category 2',
3=>'Category 3'
);

function showCats($cats){

?>
<select name="commentCats">
<?php
foreach($cats as $key=>$cat){
?>
<option value="<?php print $key; ?>"><?php print $cat; ?></option>
<?
}
?>
</select>
<?php
}
add_action ('comment_post', 'add_comment_fields', 1);
function add_comment_fields($comment_id) {
            add_comment_meta($comment_id, 'commentCats', $_POST['commentCats'], true);
}
function manifest_comment($comment, $args, $depth){
print $depth;
global $cats;
 $catID = get_comment_meta(get_comment_ID(),"commentCats", true);
 $GLOBALS['comment'] = $comment; ?>
   <li <?php comment_class(); ?> id="li-comment-<?php comment_ID() ?>">
     <div id="comment-<?php comment_ID(); ?>">
      <div class="comment-author vcard">
         <?php echo get_avatar($comment,$size='48',$default='<path_to_url>' ); ?>

         <?php printf(__('<cite class="fn">%s</cite> <span class="says">says:</span>'),         get_comment_author_link()) ?>
      </div>

      <?php if ($comment->comment_approved == '0') : ?>
         <em><?php _e('Your comment is awaiting moderation.') ?></em>
         <br />
      <?php endif; ?>

      <div class="comment-meta commentmetadata"><a href="<?php echo htmlspecialchars( get_comment_link( $comment->comment_ID ) ) ?>"><?php printf(__('%1$s at %2$s'), get_comment_date(),  get_comment_time()) ?></a><?php edit_comment_link(__('(Edit)'),'  ','') ?></div>
      <?php if($catID){ ?>
      <h3><?php 

      print $cats[$catID]; ?></h3>
    <?php } ?>
      <?php comment_text() ?>

      <div class="reply">
         <?php comment_reply_link(array_merge($args, array('depth' => $depth, 'max_depth' => $args['max_depth']))) ?>
      </div>
     </div>
<?php 
} 

?>

我无法弄清楚问题是什么,我被告知它正在使用另一台测试机器。我目前正在本地机器上测试主题。我正在使用XAMPP(http://www.apachefriends.org/en/xampp-windows.html)进行测试,其中包括Apache,MySQL,PHP和PHPmyAdmin。我正在使用全新安装的Wordpress版本3.4.1。

谢谢!

1 个答案:

答案 0 :(得分:3)

第36行 - 您在通话后忘记了;

<?php printf(__('<cite class="fn">%s</cite> <span class="says">says:</span>'),         get_comment_author_link()) ?>

编辑:正如我从评论中看到并进一步查看eclipse中的代码,您在语句后遗漏了很多;

<?php comment_text() ?>
<?php comment_reply_link(array_merge($args, array('depth' => $depth, 'max_depth' => $args['max_depth']))) ?>
相关问题