config_load函數(shù)
config_load函數(shù)
使用方式:
配置文件有可能包含多個(gè)部分,此時(shí)可以使用附加屬性 section 指定從哪一部分中取得變量.
注意:配置文件中的 section 和模板內(nèi)建函數(shù) section 只是命名相同,毫不相干。
eg:
test.html:
{config_load file="colors.conf" section="Customer"} <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>
colors.conf:
#注釋 #段落變量 [Customer] pageTitle='顧客表' bodyBgColor='#00f' tableBorderSize='1' tableBgColor='skyblue' rowBgColor='red' tableBgColor='skyblue' [Person] pageTitle='所有人表' bodyBgColor='#eee' tableBorderSize='1' tableBgColor='skyblue' rowBgColor='red' tableBgColor='skyblue' [other] other='這是其他'
運(yùn)行結(jié)果:
section="Person"時(shí)運(yùn)行結(jié)果: