解析错误:语法错误,文件意外结束 - 第 59 行 [英] Parse error: syntax error, unexpected end of file - line 59

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

问题描述

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

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

functions.php 文件已修改为允许在发表评论时选择主题"行.

代码如下:

'类别 1',2=>'类别 2',3=>'类别 3');功能 showCats($cats){?><select name="commentCats"><?phpforeach($cats as $key=>$cat){?><option value="<?php print $key; ?>"><?php print $cat;?></option><?}?></选择><?php}add_action ('comment_post', 'add_comment_fields', 1);函数 add_comment_fields($comment_id) {add_comment_meta($comment_id, 'commentCats', $_POST['commentCats'], true);}函数 manifest_comment($comment, $args, $depth){打印 $depth;全球 $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()) ?>

<?php if ($comment->comment_approved == '0') : ?><em><?php _e('您的评论正在等待审核.') ?></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打印 $cats[$catID];?></h3><?php } ?><?php comment_text() ?><div class="回复"><?php comment_reply_link(array_merge($args, array('depth' => $depth, 'max_depth' => $args['max_depth']))) ?>

<?php}?>

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

谢谢!

解决方案

第 36 行 - 您在调用后忘记了 ;:

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

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

<?php comment_reply_link(array_merge($args, array('depth' => $depth, 'max_depth' => $args['max_depth']))) ?>

This error appears up when activating a modified theme in Wordpress:

Parse error: syntax error, unexpected end of file in C:\xampp\htdocs\wp-content\themes\manifest_v1.1\functions.php on line 59

The functions.php file has been modified to allow "subject" lines to be chosen when posting a comment.

Here is the code:

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

?>

I can't figure out what the problem is, I have been told it was working on another test machine. I am currently testing the theme on a local machine. I am testing using XAMPP (http://www.apachefriends.org/en/xampp-windows.html) which includes Apache, MySQL, PHP and PHPmyAdmin. I am using a fresh installation of Wordpress version 3.4.1.

Thanks!

解决方案

Line 36 - you forgot a ; after the call:

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

Edit: as I saw from the comments and further looking at the code in eclipse, you are missing quite a few ; after statements:

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

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

查看全文
相关文章
PHP最新文章
热门教程
热门工具
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆