2012-08-09 220 views
-1

激活WordPress的经修饰的主题时,此错误出现了:解析错误:语法错误,意外的文件结束 - 线59

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

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 
} 

?> 

我想不出是什么问题,我已被告知这是工作的另一个测试机上。我目前正在本地机器上测试主题。我正在使用包含Apache,MySQL,PHP和PHPmyAdmin的XAMPP(http://www.apachefriends.org/en/xampp-windows.html)进行测试。我正在使用Wordpress版本3.4.1的全新安装。

谢谢!

+0

我添加了所有缺少分号后所有语句,我仍然收到此错误。 – 2012-08-09 16:02:23

+0

[解析错误:语法错误,我的PHP代码中的文件意外结束]的可能重复(http://stackoverflow.com/questions/11482527/parse-error-syntax-error-unexpected-end-of-file-in -My-PHP-代码)。 – 2013-07-15 03:48:40

回答

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']))) ?> 
+2

有很多缺少分号的语句 - 查看'echo()'调用或'comment_reply_link()'调用。 – nickb 2012-08-09 14:56:29

+1

和第51行'comment_text()'。 – Matt 2012-08-09 14:56:41

+1

和第54行'comment_reply_link()'。 – Matt 2012-08-09 14:57:10

相关问题