【问题标题】:Smarty-Function-Variable outside the functionSmarty-Function-函数外的变量
【发布时间】:2016-02-09 11:27:02
【问题描述】:

我的模板中有一个 smarty-function,变量 myvar 被传递到该函数中..

{function name="myfunction" myvar=""}

{/function}

变量在函数内部填充,我需要在函数外部输出这个变量..怎么办?

【问题讨论】:

    标签: php function templates variables smarty


    【解决方案1】:

    如果您在 smarty 中分配变量,您可以添加 'scope=global' 参数,如:

    {assign var="name" value="Bob" scope="global"}
    

    如果你只想在当前文档中访问变量,你可以使用

    {assign var="name" value="Bob" scope="parent"}
    

    请看 http://www.smarty.net/docs/en/language.function.assign.tpl

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2013-10-28
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-03-25
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多