?
このドキュメントでは、 php中國(guó)語ネットマニュアル リリース
Smarty - the compiling PHP template engine | ||
---|---|---|
Prev 來源:PHP中文社區(qū) | Next |
Config files are handy for designers to manage global template variables from one file. One example is template colors. Normally if you wanted to change the color scheme of an application, you would have to go through each and every template file and change the colors. With a config file, the colors can be kept in one place, and only one file needs to be updated.
配置文件有利于設(shè)計(jì)者管理文件中的模板全局變量。最簡(jiǎn)單的例子就是模板色彩變量。一般情況下你如果想改變一個(gè)程序的外觀色彩,你就必須通過去更改每一個(gè)文件的顏色變量。如果有這個(gè)配置文件的話,色彩變量就可以保存在一個(gè)地方,只要改變這個(gè)配置文件就可以實(shí)現(xiàn)你色彩的更新。
Example 9-1. Example of config file syntax 例 9-1 配置文件語法例子
|
Values of config file variables can be in quotes, but not necessary. You can use either single or double quotes. If you have a value that spans more than one line, enclose the entire value with triple quotes ("""). You can put comments into config files by any syntax that is not a valid config file syntax. We recommend using a # (hash) at the beginning of the line.
配置文件變量值能夠在引號(hào)中使用,但是沒有必要。你可以用單引號(hào)或者雙引號(hào)。如果你有一個(gè)不只在一個(gè)區(qū)域內(nèi)使用的變量值,你可以使用三引號(hào)(""")將它完整的封狀起來,可以把它們放金配置文件,只要沒有語法錯(cuò)誤。我們建議在程序行前使用 “#”加一些注釋信息來標(biāo)示。
This config file example has two sections. Section names are enclosed in brackets []. Section names can be arbitrary strings not containing [ or ] symbols. The four variables at the top are global variables, or variables not within a section. These variables are always loaded from the config file. If a particular section is loaded, then the global variables and the variables from that section are also loaded. If a variable exists both as a global and in a section, the section variable is used. If you name two variables the same within a section, the last one will be used.
上面關(guān)于配置文件的例子共有兩個(gè)部分。每部分的名稱都是用一個(gè)“[]”給括起來。每部分的名稱命名規(guī)則就是任意的字符串,只要不包括有符號(hào)“[”或者“]”。例子開頭的四個(gè)變量都是全局變量,也就是說不僅僅是可以在一個(gè)區(qū)域內(nèi)使用。這些變量總是從配置文件中載入。如果某個(gè)特定的局部變量已經(jīng)載入,這樣全局變量和局部變量都還可以載入。如果當(dāng)某個(gè)變量名既是全局變量又是局部變量時(shí),局部變量將被優(yōu)先賦予值來使用。如果在一個(gè)局部中兩個(gè)變量名相同的話,最后一個(gè)將被賦值使用。
Config files are loaded into templates with the built-in function {config_load} .
配置文件是通過內(nèi)建函數(shù)載入到模板 { config load }
You can hide variables or entire sections by prepending the variable name or section name with a period. This is useful if your application reads the config files and gets sensitive data from them that the template engine does not need. If you have third parties doing template editing, you can be certain that they cannot read sensitive data from the config file by loading it into the template.
你可以在某個(gè)段時(shí)期通過預(yù)先想好的變量名或者局部名隱藏變量或者完整的一個(gè)節(jié)。當(dāng)你的應(yīng)用程序讀取配置文件和取得有用數(shù)據(jù)而不用讀取模板時(shí)這個(gè)非常有用,如果你有第三方來做模板編輯的話,可以肯定的說它們不能通過載入配置文件到模板而讀取到任何有用的數(shù)據(jù)。
Prev 來源:PHP中文社區(qū) | Home | Next |
textformat | Up | Debugging Console |