2010-09-09 118 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