ThinkPHP中前台輸出變數

2022-04-29 08:51:06 字數 1284 閱讀 8281

1.   foreach

<

foreach

name

="list"

item

="vo"

>

|:foreach

>

也可以定義索引的變數名

<

foreach

name

="list"

item

="vo"

key="k"

>

|:foreach

>

2.  volist

<

volist

name

="list"

id="vo"

>

:<

br/>

volist

>

3.  有的公司也會使用 onethink 的 article:list

<

article:list

type

="admin"

limit

="5"

order

="orderby asc"

where

="state = '1'"

>

article:list

>

4.if標籤

<

if condition

="($name eq 1) or ($name gt 100) "

>

value1

<

elseif

condition

="$name eq 2"

/>

value2

<

else

/>

value3

if>

注:1.在condition屬性中可以支援eq等判斷表示式,同上面的比較標籤,但是不支援帶有」>」、」<」等符號的用法,因為會混淆模板解析。

2.由於if標籤的condition屬性裡面基本上使用的是php語法盡可能使用判斷標籤和switch標籤會更加簡潔,原則上來說,能夠用switch和比較標籤解決的盡量不用if標籤完成。因為switch和比較標籤可以使用變數調節器和系統變數。如果某些特殊的要求下面,if標籤仍然無法滿足要求的話,可以使用原生php**或者php標籤來直接書寫**

thinkphp 變數輸出 系統變數

1 在控制器中給模板變數賦值 action name thinkphp this assign name name this display 2 在模板中使用 tpi action html hello,或者hello,普通標籤預設開始標記是 也可以通過設定tmpl l delim和tmpl r d...

Thinkphp 框架模板變數及模板輸出

thinkphp框架 模板操作變數輸出 執行方法並輸出返回值 執行方法不輸出 輸出session變數 輸出cookie變數 輸出配置引數 輸出語言變數 輸出get變數 輸出post變數 輸出常量 模板輸出 1 直接呼叫預設 index 操作模板 this display 對應winxin tpl d...

thinkphp 模板變數輸出替換和賦值

一.變數輸出的幾個方法 二.變數替換可以在config 設定也可以用fetch第三個引數 檢視輸出字串內容替換 view replace str 123 替換內容 三.thinkphp褲架 think view.php提供了幾個全家路徑變數 basereplace root root,url bas...