您好,登錄后才能下訂單哦!
這篇文章主要介紹了thinkPHP控制器變量在模板中如何顯示,具有一定借鑒價(jià)值,感興趣的朋友可以參考下,希望大家閱讀完這篇文章之后大有收獲,下面讓小編帶著大家一起了解一下。
具體如下:
控制器中變量
public function register() { $type = I("param.type");//1.學(xué)生注冊(cè) 2.教師注冊(cè) 3.其他注冊(cè) $this -> assign("type", $type); //q全部部門 $depart1 = M("Depart") -> where("status=1 and fid=0") -> order("id asc") -> select(); $this -> assign("depart1", $depart1); $this -> display(); }
模板中引用位置一:php代碼中,直接用$i;
<php> echo $i; </php
模板中引用位置二:模板中直接應(yīng)用{$i}
或者 class="{$unlogined}"
<font color="red">注意:1.非相關(guān)人員,嚴(yán)禁注冊(cè)。{$i}</font><br> <php> $logined = is_array($_SESSION['userInfo']) ? "" : "hide-div"; $unlogined = $logined == "hide-div" ? "" : "hide-div"; </php> <div id="unlogined-div" class="{$unlogined}">
模板中引用位置三:模板標(biāo)簽中用,如condition中用,不加{}。
<if condition="$type neq 4"> <div class="form-group"> <label for="" class="control-label col-sm-3">一級(jí)部門: <span class="text-danger">*</span></label> <div class="col-sm-9"> <select name="depart1_id" id="depart1_id" onchange="depart1change()" class="form-control input-sm"> <option value="-1">-----請(qǐng)選擇一級(jí)部門-----</option> <foreach name="depart1" item="vo"> <option value="{$vo.id}">{$vo.name}</option> </foreach> </select> </div> </div> <div class="form-group"> <label for="" class="control-label col-sm-3">二級(jí)部門: <span class="text-danger">*</span></label> <div class="col-sm-9"> <select name="depart2_id" id="depart2_id" onchange="depart2change()" class="form-control input-sm"> <option selected='selected'>-----請(qǐng)先選擇一級(jí)部門-----</option> </select> </div> </div> <div class="form-group"> <label for="" class="control-label col-sm-3">三級(jí)部門: <span class="text-danger">*</span></label> <div class="col-sm-9"> <select name="depart3_id" id="depart3_id" class="form-control input-sm"> <option selected='selected'>-----請(qǐng)先選擇二級(jí)部門-----</option> </select> </div> </div> </if>
感謝你能夠認(rèn)真閱讀完這篇文章,希望小編分享的“thinkPHP控制器變量在模板中如何顯示”這篇文章對(duì)大家有幫助,同時(shí)也希望大家多多支持億速云,關(guān)注億速云行業(yè)資訊頻道,更多相關(guān)知識(shí)等著你來學(xué)習(xí)!
免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如果涉及侵權(quán)請(qǐng)聯(lián)系站長(zhǎng)郵箱:is@yisu.com進(jìn)行舉報(bào),并提供相關(guān)證據(jù),一經(jīng)查實(shí),將立刻刪除涉嫌侵權(quán)內(nèi)容。