直接定义不行么string $str=$mon

解决方案 »

  1.   

    {foreach from=$data.month|smarty:nodefaults item=mon}
      <td align="right" nowrap><span class="{$ls.mon_1_color|default:"txt12"}">{$ls.mon_'$mon'|custom_number_format}</span></td>
    {/foreach}  不行吧 
    这是整段代码  就为取出 一个月份 数拼接后 取出结果
      

  2.   

    试试:$id="111";
    echo $str=(string)$id;
      

  3.   

    不行吧   4就是$mon $mon是显示了 但是 结果没了我在整个 {$ls.mon_'$mon'|custom_number_format} 加了"号{"$ls.mon_'$mon'|custom_number_format"} 页面显示变成了Array.mon_4|custom_number_format  如何才能正确拼接阿
      

  4.   


    $ls.mon_'$mon'|custom_number_format} // $mon 变量不能加单引号
      

  5.   

    不加显示也是Array.mon_4|custom_number_format  大大帮忙
      

  6.   

    没明白你的意思!
    你是要把$mon直接显示成$mon么?还是要显示$mon的值?
      

  7.   

    不知道你是不是这个意思:
    {$ls."mon_".$mon|custom_number_format}
      

  8.   

    $ls.mon_$mon 本来是 $ls.mon_1 -- $ls.mon_12   我现在用变量拼接 $ls.mon_1 - 12 是有结果的 我要根据循环显示他们的结果 可是 就是因为拼接 问题 无法 进行下去了
      

  9.   

    要是拼接问题的话,应该是这样写:$ls.".mon_".$mon."|custom_number_format"
      

  10.   

    smarty拼接串不是用.,用cat{$ls|cat:"mon_"|cat:$mon|custom_number_format}
      

  11.   

    是不是字符串的拼接:试下
    $ls."mon_".$mon."|custom_number_format"