Heim  >  Fragen und Antworten  >  Hauptteil

Stellen Sie eine Frage zur Thinkphp-Syntax

Im HTML in thinkphp
Ich möchte feststellen, ob $huodong.id und $vo.xueduanid gleich sind.

                        xueduanid:{$vo.xueduanid}huodongid:{$huodong.id}
                        
                        

Ausgabe xueduanid:1huodongid:1

            <if condition="$vo.xueduanid == $huodong.id">eee</if>

Aber eee kann so nicht ausgegeben werden. Warum? Sie sind alle 1. Sie sollten gleich sein? Falscher Typ? Die Werte in der Datenbank sind alle vom Typ int. .

<if condition="$vo.xueduanid == 1">eee</if>kann eee ausgeben
<if condition="$huodong.id==1">eee</if>kann eee ausgeben

滿天的星座滿天的星座2712 Tage vor544

Antworte allen(4)Ich werde antworten

  • 仅有的幸福

    仅有的幸福2017-05-17 09:57:51

    == 改成eq

    Antwort
    0
  • 伊谢尔伦

    伊谢尔伦2017-05-17 09:57:51

    直接用eq

    <eq name="vo.xueduanid" value="huodong.id">
    相等
    <else/>
    不等
    </eq>

    Antwort
    0
  • PHP中文网

    PHP中文网2017-05-17 09:57:51

    <if condition="$vo.xueduanid eq $huodong.id">
    相等
    <else/>
    不等
    </if>

    Antwort
    0
  • 習慣沉默

    習慣沉默2017-05-17 09:57:51

    其实TP的模板引擎有点BUG,上面说的理论上都对,但其实要写成

    <if condition="$vo.xueduanid eq $huodong['id']">eee</if>

    后面那个变量要用数组形式写,不然转成PHP代码的时候会出错。

    Antwort
    0
  • StornierenAntwort