W3Cschool
恭喜您成為首批注冊(cè)用戶
獲得88經(jīng)驗(yàn)值獎(jiǎng)勵(lì)
{config_load}
用于從配置文件中 加載配置變量#variables#
。
屬性:
參數(shù)名稱 | 類型 | 必選參數(shù) | 默認(rèn)值 | 說(shuō)明 |
---|---|---|---|---|
file | string | Yes | n/a | 載入的配置文件名 |
section | string | No | n/a | 指定載入配置變量的段落 |
scope | string | no | local | 配置變量的作用范圍,取值local, parent 或 global. local表示變量只能在當(dāng)前模板的上下文中使用。 parent表示變量可以在當(dāng)前模板和父模板使用。 global表示變量在任何地方都可用。 |
Example 7.24. {config_load}
example.conf
配置文件.
#this is config file comment # global variables pageTitle = "Main Menu" bodyBgColor = #000000 tableBgColor = #000000 rowBgColor = #00ff00 #customer variables section [Customer] pageTitle = "Customer Info"
模板是:
{config_load file="example.conf"} {config_load "example.conf"} {* short-hand *} <html> <title>{#pageTitle#|default:"No title"}</title> <body bgcolor="{#bodyBgColor#}"> <table border="{#tableBorderSize#}" bgcolor="{#tableBgColor#}"> <tr bgcolor="{#rowBgColor#}"> <td>First</td> <td>Last</td> <td>Address</td> </tr> </table> </body> </html>
配置文件 可能會(huì)有一些段落。你可以用section
屬性單獨(dú)載入某個(gè)指定段落的配置變量。 注意全局的配置變量會(huì)同時(shí)被載入,同名的段落配置變量會(huì)覆蓋全局的配置變量。
配置文件的sections和內(nèi)置函數(shù){section}
是不相關(guān)的,它們只是剛好名稱比較像。
Example 7.25. {config_load} 載入段落配置變量
{config_load file='example.conf' section='Customer'} {config_load 'example.conf' 'Customer'} {* short-hand *} <html> <title>{#pageTitle#}</title> <body bgcolor="{#bodyBgColor#}"> <table border="{#tableBorderSize#}" bgcolor="{#tableBgColor#}"> <tr bgcolor="{#rowBgColor#}"> <td>First</td> <td>Last</td> <td>Address</td> </tr> </table> </body> </html>
Copyright©2021 w3cschool編程獅|閩ICP備15016281號(hào)-3|閩公網(wǎng)安備35020302033924號(hào)
違法和不良信息舉報(bào)電話:173-0602-2364|舉報(bào)郵箱:jubao@eeedong.com
掃描二維碼
下載編程獅App
編程獅公眾號(hào)
聯(lián)系方式:
更多建議: