2010-09-09 115 views
0

這裏是我不斷收到錯誤:解析錯誤:語法錯誤意外T_DOUBLE_ARROW厚望「)」

解析錯誤:語法錯誤,意想不到的T_DOUBLE_ARROW,預計「)」在... /主題/默認/ Display.template .PHP上線170

下面的代碼:

'notify' => array(
    'test' => 'can_mark_notify', 
    'text' => 125, 
    'image' => 'notify.gif', 
    'lang' => true, 
    'custom' => 
     'onclick="return confirm(Â¥'' 
     . (
      $context['is_marked_notify'] 
      ? $txt['notification_disable_topic'] 
      : $txt['notification_enable_topic'] 
     ) 
     . 'Â¥');"', 
    'url' => $scripturl 
     . '?action=notify;sa=' 
     . ($context['is_marked_notify'] ? 'off' : 'on') 
     . '; topic=' . $context['current_topic'] 
     . '.' . $context['start'] 
     . '; sesc=' 
     . $context['session_id']), 

我檢查,看看是否所有的括號被關閉,他們似乎是。我不知道該怎麼做。

回答

3

你有不平衡的單引號開始在'custom => 'onclick=...你插入一些PHP數組變量到javascript中。

'notify' => array(
    'test' => 'can_mark_notify', 
    'text' => 125, 
    'image' => 'notify.gif', 
    'lang' => true, 
    'custom' => 'onclick="return confirm(Â¥'' . ($context['is_marked_notify'] ? 
             ^^^^^ right here 
      $txt['notification_disable_topic'] : $txt['notification_enable_topic']) . 'Â¥');"', 
    'url' => $scripturl . '?action=notify;sa=' . ($context['is_marked_notify'] ? 'off' : 'on') . ';topic=' . $context['current_topic'] . '.' . $context['start'] . ';sesc=' . $context['session_id']), 

同樣,你應該非常小心地將看起來像文本的東西插入到那些onclick處理程序中。如果$txt['notification_disable_topic']及其他文件包含單引號(例如「O'Brien」),該怎麼辦?你最終會出現javascript語法錯誤。

+0

我對編碼一無所知。我如何解決這個問題?抱歉缺乏理解。 – Phill 2010-09-09 17:37:24

+0

哦,它就這樣了。謝謝! – Phill 2010-09-09 18:03:44

+0

您必須關閉Marc在其評論開始時寫的字符串 – 2010-09-09 18:04:25