Concatenation in smarty

后端 未结 3 1352
醉梦人生
醉梦人生 2021-02-05 05:28

I want to assign the value obtained from the concatenation of these two variables with a string.

{assign var=\"url\" value=\"{$WS_PATH}aircraft_images/{$images[i         


        
3条回答
  •  爱一瞬间的悲伤
    2021-02-05 05:59

    You've used assign properly.

    A simplified example could look like this:

    yourphpfile.php:

    $tpl = new Smarty;
    $tpl->assign('var1','Hello');
    $tpl->assign('var2','World');
    $tpl->display('yourtemplate.tpl');
    

    yourtemplate.tpl:

    ...
    
    {assign var="url" value="{$var1} - and - {$var2}"}
    {$url}
    
    

    ...will result to the output:

    Hello - and - World
    

提交回复
热议问题