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

无码一区二区三区高清在线观-无码一区二区三区高清在线-无码一区二区三区电影-无码一区二区三区不卡av-无码一区二区三区不卡-无码一区二区三区va在线播放

首頁 > 職業資格  > 

利用PHP引擎smarty(3)

2022-12-30   來源:萬能知識網

利用PHP模板引擎smarty


(資料圖片)

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

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

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

#section屬性可賦三種值

#local 只有當前模版可以使用該配置文件

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

#global 測試效果和parent相同

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

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

*/

/*

tpl文件中常用函數

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循環,類似PHP代碼*}

{$x=0}

{while $x

{$x++}

{/while}

{*While循環,也類似PHP代碼。*}

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

{$arId}對應的值為:{$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

詞條內容僅供參考,如果您需要解決具體問題
(尤其在法律、醫學等領域),建議您咨詢相關領域專業人士。

標簽

配置文件

推薦詞條

主站蜘蛛池模板: 免费在线看污网站 | 亚州免费一级毛片 | 亚洲欧美日韩中文字幕久久 | 亚洲中文字幕久久精品码 | 日本A片特黄久久免费观看 日本A片中文字幕精华液 | 99好久被狂躁A片视频无码 | 国产精品成人a区在线观看 国产精品成人a在线 | 国产三级电影 | 免费看欧美成人A片无码 | 久久无码精品亚洲日韩av | 久久无码AV亚洲精品色午夜 | 成人欧美激情亚洲日韩蜜臀 | 一级毛片不卡片免费观看 | 免费一级毛片视频 | 亚洲国产天堂久久综合夜 | 久久精品国产日本一区二区 | 国产成人拍精品视频午夜网站 | 免费三圾片在线观看 | 亚洲日本在线观看视频 | 国产亚洲精品久久久一区 | 亚洲三级国产 | 2024精品国产a不卡片 | 久久精品国产免费高清 | 51社区精品视频 | 97久久精品无码一区二区 | av免费播放一区二区三区 | 2024年理论免费播放 | 1024亚洲欧美 | a级毛片免费全部播放a级 | 日日摸夜夜添夜夜添A片一Y | 激情综合色综合啪啪开心 | 91精品国产综合久久福利 | 日本xxx在线观看免费播放 | 亚洲久热无码中文字幕人妖 | 熟女乱色综合一区小说 | 国产成人av一区二区三区在 | 午夜免费福利观看 | 国产美女视频一区二区二三区 | 久久精品免费看 | 久久久久久久99久久久毒国产 | 妓女妓女一区二区三 |