2013-07-30 23 views
0

我一直在處理這個問題,我不知道如何解決它。 我搜索了這個問題,發現我的問題發生在這裏的其他人。我試圖盡我最大的能力,遵循人都建議他們的步驟,但它似乎仍然是我收到我的網頁上出現以下錯誤:在functions.php文件中意外的結束 - Wordpress

解析錯誤:語法錯誤,意想不到的$結束/愛馬仕上線56

/waloraweb015/b1446/as.allthingsnetwork/blog/wp-content/themes/atn/functions.php通過研究,我的理解是錯誤意味着有沒有被關閉或丟失的括號「 ;」在文件中。我試圖解決這些問題無濟於事,所以我在這裏發佈我的代碼,並且可能會收到一些善意幫助的人的回覆。

的functions.php:

<?php 
// Enable support for post-thumbnails 

add_theme_support('post-thumbnails'); 

if (function_exists('add_theme_support')) { 
    add_theme_support('post-thumbnails'); 
} 

function wpbeginner_remove_comment_url($arg) { 
    $arg['url'] = ''; 
    return $arg; 
} 
add_filter('comment_form_default_fields', 'wpbeginner_remove_comment_url'); 


function wpbeginner_comment_text_after($arg) { 
    $arg['comment_notes_before'] = "Let us know if you like this track</a>!"; 
    return $arg; 
} 

add_filter('comment_form_defaults', 'wpbeginner_comment_text_after'); 

    function custom_comments($comment, $args, $depth) { 

     $GLOBALS['comment'] = $comment; ?> 

     <div class="alignleft"> 
     <?php echo get_avatar(get_the_author_ID()); ?> 
     </div> 

     <li <?php comment_class(); ?> id="li-comment-<?php comment_ID(); ?>"> 

      <div class="comment-intro"> 
       <h3><?php printf(__('%s'), get_comment_author_link()); ?></h3> 
       <a class="comment-permalink" href="<?php echo htmlspecialchars (get_comment_link($comment->comment_ID)) ?>"><?php printf(__('%1$s'), get_comment_date()); ?> 
      </a> 
      <em> | </em> 
      <a class="comment-permalink" href="<?php echo htmlspecialchars (get_comment_link($comment->comment_ID)) ?>"> 
       <?php comment_time(); ?> 
      </a> 
      </div> 

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

      <div class="comment-text"> 
      <?php comment_text(); ?> 
      </div><br /> 

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

} 
?> 

非常感謝你提前給任何人願意幫助我, 安東尼。

+0

我不能感謝你足夠的大獎賽,這個解決方案完美地工作! – Anthony

回答

2

在你到底有:

} 
?> 

應該是:

<?php 
} 
?> 

這裏

<php _e('Your comment is awaiting moderation.') ?> 

應該是:

<?php _e('Your comment is awaiting moderation.'); ?> 

最後在這裏,請注意你有像這樣兩次:

<?php echo htmlspecialchars (get_comment_link($comment->comment_ID)) ?> 

應該是:

<?php echo htmlspecialchars (get_comment_link($comment->comment_ID)); ?> 
+0

值得注意的是,第一位(即'')是導致錯誤的原因。其餘的只是最佳實踐。 –

+0

@NickQ。不,在某些情況下,如果你沒有正確關閉你的回聲,它也會產生錯誤。 [請看這裏一個非常簡單的例子](https://eval.in/39864) – Prix

+0

你說得對,如果任何一行沒有結束,PHP將不知道如何處理另一個語句/行。然而,在提供的場景中,'?>'有效地結束了這一行,因此這不是導致錯誤的原因。 _ ** YES ** _,如果您決定添加代碼塊,那麼使用分號絕對有意義,不要說統一性。但這是否會導致安東尼的問題?號碼 –