configLoad('test.conf')則只使用全局的">

jizzjizz欧美69巨大,久久成人国产精品二三区,欧美日本成人一区二区三区,青青操精品在线观看视频

首頁 > 職業(yè)資格  > 

利用PHP引擎smarty(3)

2022-12-30   來源:萬能知識(shí)網(wǎng)

利用PHP模板引擎smarty


(資料圖片)

#$sections參數(shù)可以不寫,默認(rèn)值為null,$smarty->configLoad("test.conf")則只使用全局的鍵值,而不能使用標(biāo)簽下的鍵值

#在模版下通過{config_load file="test.conf" section="china" scope="global"}語句調(diào)用配置文件

#section屬性可以不寫,默認(rèn)是null,scope屬性必須寫{config_load file="test.conf" scope="global"}

#section屬性可賦三種值

#local 只有當(dāng)前模版可以使用該配置文件

#parent 只有當(dāng)前模版引入該配置文件語句后包含的模版中,或在php源文件中smarty對象調(diào)用該配置文件后調(diào)用的模版中可以使用該配置文件中的鍵值

#global 測試效果和parent相同

#在模版中通過{#language#}來使用鍵值,也可以通過{$smarty.config.language}來訪問配置文件鍵值

#PHP源文件中可以使用$smarty->getConfigVars("language")或$smarty->getConfigVariable("language")來獲取鍵值,$smarty->getConfigVars("language")獲取的還可能是數(shù)組

*/

/*

tpl文件中常用函數(shù)

tpl文件:

{capture name="testCapture"}

{include file="f1.tpl"}

{/capture}

{if true}

{$smarty.capture.testCapture}

{/if}

{if $name == "wang"}

Welcome wang.

{elseif $name == "zhang"}

Welcome zhang.

{else}

Welcome, whatever you are.

{/if}

{*操作符可以是 ==,>= 等也可以是 eq,ne等*}

{for $x=0; $x

{$x}

{/for}

{*for循環(huán),類似PHP代碼*}

{$x=0}

{while $x

{$x++}

{/while}

{*While循環(huán),也類似PHP代碼。*}

{foreach name="testForeach" from=$testArr key=arId item=arVal}

{$arId}對應(yīng)的值為:{$arVal}

{$smarty.foreach.testForeach.index} ?

{$smarty.foreach.testForeach.iteration} ?

{$smarty.foreach.testForeach.first}

{$smarty.foreach.testForeach.last}

{$smarty.foreach.testForeach.total}

{foreachelse}

$testArr is null

{/foreach}

{*也可以如下兩種類PHP格式*}

{foreach $testArr as $n}

{$n}

{/foreach}

{foreach $testArr as $key=>$n}

{$key}

{/foreach}

{$sectionArr = [0=>"a",4=>"b","c","d","e",6,7,8,9,10,11,12,13,14,15,16]}

{section name="testSection" loop=$sectionArr start=0 step=4 max=6 show=true}

{$smarty.section.testSection.index}-

{$sectionArr[testSection]}-

{$smarty.section.testSection.iteration}-

{sectionelse}

$sectionArr is null

{/section}

*/

/*

tpl模板文件:

{literal}

script type="text/javascript"

function a(){

alert("this is script");

}

a();

/script

詞條內(nèi)容僅供參考,如果您需要解決具體問題
(尤其在法律、醫(yī)學(xué)等領(lǐng)域),建議您咨詢相關(guān)領(lǐng)域?qū)I(yè)人士。

標(biāo)簽

配置文件

推薦詞條

日韩精品欧美精品一区二区| 大鸡吧操小逼逼| 中文字幕av久久一区二区| 91青娱乐极品| 亚洲男人的天堂视频在线| 日韩一区二区中文字幕不卡| 99热这里只有的精品8| 靠逼免费视频现在马上看| 成人亚洲一区二区在线观看| 免费看操逼逼的视频网站| 欧美xoxoxoxo免费| 大鸡巴搞逼视频| 男女野外操逼欧美大鸡吧| 成人影院点击即入爽不停| 国产噜噜噜精品免费视频| 国产明星三级在线看视频| 国产老人一区av二三区| 被老男人插爽了免费视频| 大奶子女人爆操| 欧美日韩亚洲精品吊丝网| 日韩欧美一区二区福利视频| 国产办公室沙发系列高清| 女人大屁股三级黄色视频| 亚洲欧美一区二区三区国产| 成+人+亚洲+综合天堂| 精品国产91久久粉嫩懂色| 奇米色奇米影视在线观看| 久久久精品综合| 韩国主播午夜大尺度福利| 韩漫无羞遮无删减漫免费| 精品国产成人国产在线视| 色欲aⅴ激情情无码AV| 大鸡巴日老女人| 小美女操比黄片| 久久国产精品久久国产精品| 奇米影视第四色 777| 爱啪网在线观看| 国产午夜在线观看一片红| 久久久久久久久久久久38| 日本欧美精品A中文在线| se色综合一区二区二区|