Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
如果我的模板查找未分配的变量会发生什么?
例如:
var id = '{$tpl_id}';
这个片段来自我的 javascript 代码。我输出了这个值,它只是空的。我知道我可以使用 isset()。但我找不到任何关于 Smarty 如何处理不存在的变量的信息。那么,如果模板找不到变量,因为它没有被分配,会发生什么?
如果未定义变量,则将其视为空变量。不会发生(非逻辑)错误。
你必须使用 {literal} {/literal} 示例:
literal} {/literal}
{literal} <script> var id = '{/literal}{$tpl_id}{literal}'; // keep coding </script> {/literal}