开发者

Parse Error: Syntax Error unexpected T_DOUBLE_ARROW expection ')'

开发者 https://www.devze.com 2023-01-15 06:29 出处:网络
here\'s the error I keep getting: Parse error: syntax error, unexpected T_DOUBLE_ARROW, expecting \')\' in .../Themes/default/Dis开发者_Go百科play.template.php on line 170

here's the error I keep getting:

Parse error: syntax error, unexpected T_DOUBLE_ARROW, expecting ')' in .../Themes/default/Dis开发者_Go百科play.template.php on line 170

Here's the code:

'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']),

I've checked to see if all of the parentheses are closed and they seem to be. I'm not sure what to do.


You've got unbalanced single quotes starting at the 'custom => 'onclick=... where you insert some PHP array variables into the 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']),

As well, you should be very careful inserting what appears to be text into those onclick handlers. What if $txt['notification_disable_topic'] and the rest contain a single quote (e.g. "O'Brien"). You'll end up with a javascript syntax error.

0

精彩评论

暂无评论...
验证码 换一张
取 消