0

我的网站不再工作了。我收到以下错误:

第 8 行模板“tpl_head:tpl_head:16”中的语法错误“!function(f,b,e,v,n,t,s){if(f.fbq)return;n=f.fbq=function() {n.callMethod?n.callMethod.apply(n,arguments):n.queue.push(arguments)};" - 意外的“.”,应为以下之一:“”、“”、“)”

我一直在努力寻找解决问题的方法。但我一直在死胡同。

堆栈跟踪如下:

0 /lib/smarty/sysplugins/smarty_internal_templateparser.php(2727): Smarty_Internal_TemplateCompilerBase->trigger_template_error()

1 /lib/smarty/sysplugins/smarty_internal_templateparser.php(2786): Smarty_Internal_Templateparser->yy_syntax_error(45, '.')

2 /lib/smarty/sysplugins/smarty_internal_smartytemplatecompiler.php(114): Smarty_Internal_Templateparser->doParse(45, '.')

3 /lib/smarty/sysplugins/smarty_internal_templatecompilerbase.php(404): Smarty_Internal_SmartyTemplateCompiler->doCompile('\r\n...', true)

4 /lib/smarty/sysplugins/smarty_internal_templatecompilerbase.php(336):Smarty_Internal_TemplateCompilerBase->compileTemplateSource(对象(Smarty_Internal_Template),假,空)

5 /lib/smarty/sysplugins/smarty_template_compiled.php(204): Smarty_Internal_TemplateCompilerBase->compileTemplate(Object(Smarty_Internal_Template))

6 /lib/smarty/sysplugins/smarty_template_compiled.php(100): Smarty_Template_Compiled->compileTemplateSource(Object(Smarty_Internal_Template))

7 /lib/smarty/sysplugins/smarty_template_compiled.php(163):Smarty_Template_Compiled->进程(对象(Smarty_Internal_Template))

8 /lib/smarty/sysplugins/smarty_internal_template.php(206): Smarty_Template_Compiled->render(对象(Smarty_Internal_Template))

9 /lib/smarty/sysplugins/smarty_internal_templatebase.php(216):Smarty_Internal_Template->渲染(假,0)

10 /lib/smarty/sysplugins/smarty_internal_templatebase.php(107):Smarty_Internal_TemplateBase->_execute(对象(Smarty_Internal_Template),NULL,NULL,NULL,0)

11 index.php(161): Smarty_Internal_TemplateBase->fetch()

12 {主要}

如果有人可以帮助我了解可能是什么问题,我将不胜感激。请帮忙。

4

1 回答 1

1

问题是 Smarty(使用的 PHP 模板引擎)试图立即解析任何大括号 {} 内的所有内容,即您的 javascript。

所以你可以:

  1. 在你的 JavaScript 外部放置 {literal} {/literal} 标签

  2. 在您的 javascript 中,在每个左大括号后面加上一个空格“{”,在每个右大括号前面加上一个空格“}”。这告诉 Smarty 这不是 Smarty 代码,不要解析它。

  3. 将您的 javascript 放在一个单独的文件中

于 2020-05-21T15:48:22.903 回答