Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/271.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php JavaScript语法更正中的smarty变量_Php_Smarty - Fatal编程技术网

Php JavaScript语法更正中的smarty变量

Php JavaScript语法更正中的smarty变量,php,smarty,Php,Smarty,我试图在JavaScript中使用这个变量,但我得到了语法错误 <script type="text/javascript"> {literal} $.get("mypage.php", { phone:{/literal} "{$smarty.request.phone}"{literal}, time:{/literal}"{$smarty.request.time}"{literal} } ); {/literal} </script> {literal} $

我试图在JavaScript中使用这个变量,但我得到了语法错误

<script type="text/javascript">
{literal} 
$.get("mypage.php", { phone:{/literal} "{$smarty.request.phone}"{literal},
time:{/literal}"{$smarty.request.time}"{literal} } );
{/literal}
</script>

{literal}
$.get(“mypage.php”,{phone:{/literal}{$smarty.request.phone}{literal},
时间:{/literal}{$smarty.request.time}{literal}});
{/literal}
试试:

{literal} $.get(“mypage.php”, {phone:“{$smarty.request.phone}” ); {/literal}
请注意,使用Smarty3,您不再需要在JS和CSS代码块中使用
{literal}
。在Smarty3中,Smarty不会解析被空格包围的大括号,因此:

if (a == b) { return c; } // Is not parsed by Smarty3
if (a == b) { return {$c}; } // Only {$c} is parsed
if (a == b) {return c;} // This is parsed because there are no white-spaces near braces.

Ref:,“{”和“}”(Javascript)自动转义

刚刚将相关代码粘贴到这里,其他jquery lib已经包含在内,因此要抓住要点,浏览器中的代码是什么样子的(即Smarty使用它之后)?这是唯一与JS相关的东西。earliar代码也是实际的代码(只有1“)”丢失了这只是我现在打印的代码的另一部分。确切的错误短语没有粘贴,但它是语法错误,产生错误的行已经粘贴在这里。THX无需否决投票。是的,是的,这是实际的代码,当然;除了那一半不见了。好吧,抱歉,如果你生气了,但是恕我直言,所谓的一半是毫无用处的,但是再次提醒你,我按照你所说的修改了代码,如果你仍然想要的话,我会再次发布实际代码。你确定行得通吗?这对我来说一点用都没有?!除非它使用了我从未见过的功能。
if (a == b) { return c; } // Is not parsed by Smarty3
if (a == b) { return {$c}; } // Only {$c} is parsed
if (a == b) {return c;} // This is parsed because there are no white-spaces near braces.