搜索

首页  >  问答  >  正文

thinkphp 5.1 模板中三元比较失效

<select name="tra_num">
        <option value="" {$num_tra=="%"?'selected':''}>全部</option>
        {volist name="list_tra" id="arr_tra" empty="没有文章"}
        <option value="{$arr_tra.id}" { {$num_tra} == {$arr_tra.id} ?'selected':''}>{$arr_tra.id}</option>
        {/volist}
      </select>

这样写双花括号无效  从调试程序中看是以下状况

<select name="tra_num">
        <option value="" >全部</option>
                <option value="1" { (7 == 1 ?'selected':'')}>1</option>
                <option value="2" { (7 == 2 ?'selected':'')}>2</option>
                <option value="4" { (7 == 4 ?'selected':'')}>4</option>
                <option value="5" { (7 == 5 ?'selected':'')}>5</option>
                <option value="6" { (7 == 6 ?'selected':'')}>6</option>
                <option value="7" { (7 == 7 ?'selected':'')}>7</option>
              </select>
    </div>

凡人凡人1826 天前1176

全部回复(1)我来回复

  • 殘留の回憶

    殘留の回憶2019-12-05 18:53:07

    中文的{吧,还是你改了模板标签了

    回复
    0
  • 取消回复