<ruby id="bdb3f"></ruby>

    <p id="bdb3f"><cite id="bdb3f"></cite></p>

      <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
        <p id="bdb3f"><cite id="bdb3f"></cite></p>

          <pre id="bdb3f"></pre>
          <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

          <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
          <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

          <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                <ruby id="bdb3f"></ruby>

                合規國際互聯網加速 OSASE為企業客戶提供高速穩定SD-WAN國際加速解決方案。 廣告
                <table width="100%" summary="Header navigation table" border="0" cellpadding="0" cellspacing="0"><tr><th colspan="3" align="middle">Smarty - the compiling PHP template engine</th></tr><tr><td width="20%" align="left" valign="bottom"><a accesskey="P" href="smarty.constants.html">Prev</a></td><td width="80%" align="middle" valign="bottom"/><td width="10%" align="right" valign="bottom"><a accesskey="N" href="api.functions.html">Next</a></td></tr></table> # Chapter 12. Smarty Class Variables 第十二章.Smarty類變量 **Table of Contents [內容列表]**[$template_dir](#) [模板目錄變量] [$compile_dir](#) [編譯目錄變量] [$config_dir](#) [配置目錄變量] [$plugins_dir](#) [插件目錄變量] [$debugging](#) [調試變量] [$debug_tpl ](#)[調試模板變量] [$debugging_ctrl](#) [調試控制變量] [$auto_literal](#) [自動忽略解析] [$autoload_filters](#) [自動加載過濾器變量] [$compile_check](#) [編譯檢查變量] [$force_compile](#) [強迫編譯變量] [$caching](#) [緩存變量] [$cache_dir](#) [緩存目錄變量] [$cache_lifetime](#) [緩存生存時間變量] [$cache_handler_func](#) [緩存處理函數變量] [$cache_modified_check](#) [緩存修正檢查變量] [$config_overwrite](#) [配置.覆蓋變量] [$config_booleanize](#) [配置.布爾型變量] [$config_read_hidden](#) [配置.讀取隱藏變量] [$config_fix_newlines](#) [配置.固定換行符變量] [$default_template_handler_func](#) [默認模板處理函數變量] [$php_handling](#) [PHP處理變量] [$trusted_dir](#) [信任目錄變量] [$left_delimiter](#) [左定界符變量] [$right_delimiter](#) [右定界符變量] [$compiler_class](#) [編譯類變量] [$request_vars_order](#)[](#)[變量順序變量] [$request_use_auto_globals](#) [自動全局變量] [$compile_id](#) [編譯ID變量] [$use_sub_dirs](#) [子目錄變量] [$default_modifiers](#) [默認調節器變量] [$default_resource_type](#) [默認源類型變量] These are all of the available Smarty class variables. You can access them directly, or use the corresponding setter/getter methods. 本章列舉了所有有效的Smarty類變量,你可以直接訪問它們,或者使用對應的setter/getter方法。 <table width="80%" border="0" cellpadding="2" cellspacing="2" class="note"><caption> 提示 </caption> <tr><td>Note<br/> All class variables have magic setter/getter methods available. setter/getter methods are camelCaseFormat, unlike the variable itself. So for example, you can set and get the $smarty-&gt;template_dir variable with $smarty-&gt;setTemplateDir($dir) and $dir = $smarty-&gt;getTemplateDir() respectively.<br/> 所有類變量都有自己的魔術setter/getter方法,setter/getter方法為駝峰命名格式(譯注:類方法見下一章),這與變量本身不同(譯注:類變量正如你所見到的,為單詞間加下劃線'_')。因此,舉例說,你可以使用$smarty-&gt;setTemplateDir($dir)和$dir = $smarty-&gt;getTemplateDir()分別設置和讀取$smarty-&gt;template_dir變量。</td> </tr></table> <table width="80%" border="0" cellpadding="2" cellspacing="2" class="note"><caption> 提示 </caption> <tr><td>Note<br/> See Changing settings by template section for how to change Smarty class variables for individual templates.<br/> 關于怎樣設置個別Smarty類變量部份參考<a href="advanced.features.changing.settings.by.tem.html">通過模板更改設置</a>章節。</td> </tr></table> # $template_dir[模板目錄變量] This is the name of the default template directory. If you do not supply a resource type when including files, they will be found here. By default this is "./templates", meaning that it will look for the templates directory in the same directory as the executing php script. 該變量定義默認模板目錄的名字。當包含文件時,如果未提供一個源類型(即源地址),那么將會到模板目錄中尋找。默認情況下,目錄是:“./templates”,也就是說他將會在和php執行腳本相同的目錄下尋找模板目錄。 <table width="80%" border="0" cellpadding="2" cellspacing="2" class="note"><caption> 技術提示 </caption> <tr><td>Technical Note: It is not recommended to put this directory under the web server document root.<br/> 不推薦把模板目錄放在web服務器根目錄下。</td> </tr></table> **譯者例:模板文件夾移位時,模板目錄變量路徑的問題** <table border="0" bgcolor="#E0E0E0" width="100%"><tr><td><p>Smarty不推薦將模板文件、配置文件放置在服務器目錄下,以Smarty自帶的demo文件夾為示例,這時我們可以在demo下新建一個文件夾存放php腳本文件和編譯文件,比如這個新文件夾命名為‘abc’,以文件夾abc為服務器根目錄,這樣就避開了問題。這時模板目錄變量的路徑寫法則應改變,不然Smarty找不到模板文件。</p> <p>include_once('../../libs/Smarty.class.php'); //這時以文件夾abc為相對路徑為基點<br/> $smarty = new Smarty;<br/> $smarty-&gt;assign('abc','hello!');<br/> $tpl= $smarty-&gt;createTemplate('../templates/test.html',$smarty); //這里寫基于abc文件夾位置的模板文件相對路徑<br/> $tpl-&gt;display();<br/> 這時你可以看到在abc下自建了一個編譯目錄。<br/><br/> 當然也可以設置$template_dir的絕對路徑:<br/> include_once('../../libs/Smarty.class.php');<br/> $smarty = new Smarty;<br/> $tem_dir = $smarty-&gt;template_dir = 'c:/xx/xxx/smarty/demo/templates/';<br/> $smarty-&gt;assign('abc','hello!');<br/> $tpl= $smarty-&gt;createTemplate($tem_dir.'test.html',$smarty);<br/> $tpl-&gt;display();<br/></p></td> </tr></table> # $compile_dir[編譯目錄變量] This is the name of the directory where compiled templates are located. By default this is ./templates_c, meaning that Smarty will look for the templates_c/ directory in the same directory as the executing php script. This directory must be writeable by the web server, see install for more info. 本變量定位編譯模板的目錄名字。默認情況下,目錄是:“./templates_c”,也就是說他將會在和php執行腳本相同的目錄下尋找“./templates_c”編譯目錄。該目錄在服務器中必須可寫,參考[安裝](#)一節。 <table width="80%" border="0" cellpadding="2" cellspacing="2" class="note"><caption> 技術提示 </caption> <tr><td><b>Technical Note: </b> This setting must be either a relative or absolute path. include_path is not used for writing files.<br/> 該設置必須是一個相對或絕對路徑。包含路徑不可用于寫文件。 </td> </tr></table> <table width="80%" border="0" cellpadding="2" cellspacing="2" class="note"><caption> 技術提示 </caption> <tr><td><b>Technical Note: </b> It is not recommended to put this directory under the web server document root.<br/> 不推薦把編譯目錄放在web服務器根目錄下。</td> </tr></table> # $config_dir[配置目錄變量] This is the directory used to store config files used in the templates. Default is "./configs", meaning that it will look for the configs directory in the same directory as the executing php script. 本變量用于設置存放模板配置文件的目錄,默認情況下,目錄是:“./configs”,這意味著它將會在和php執行腳本相同的目錄下搜索配置目錄。 <table width="80%" border="0" cellpadding="2" cellspacing="2" class="note"><caption> 技術提示 </caption> <tr><td>Technical Note: It is not recommended to put this directory under the web server document root. <br/> 不推薦把編譯目錄放在web服務器根目錄下。 </td> </tr></table> # $plugins_dir[插件目錄變量] This is the directory or directories where Smarty will look for the plugins that it needs. Default is plugins/ under the SMARTY_DIR. If you supply a relative path, Smarty will first look under the SMARTY_DIR, then relative to the current working directory, then relative to the PHP include_path. If $plugins_dir is an array of directories, Smarty will search for your plugin in each plugin directory in the order they are given. 本變量設置Smarty尋找所需插件的目錄。默認是在SMARTY_DIR(即Smarty類所在目錄)目錄下的“plugins”目錄。如果提供了一個相對路徑,Smarty將首先在SMARTY_DIR目錄下尋找,然后到當前工作目錄下尋找,繼而到php包含路徑中的每個路徑中尋找。如果$plugins_dir是個目錄數組,那么Smarty將根據給定的命令在目錄數組中逐個搜索所需插件。 <table width="80%" border="0" cellpadding="2" cellspacing="2" class="note"><caption> 技術提示 </caption> <tr><td><p>Technical Note<br/> For best performance, do not setup your $plugins_dir to have to use the PHP include path.Use an absolute pathname, or a path relative to SMARTY_DIR or the current working directory.</p> <p>為了獲取最佳性能,不要將$plugins_dir設置為必須使用php包含路徑(包含include()、include_once()、request()、request_once()等函數)的地步。可以設置為絕對路徑、SMARTY_DIR的相對路徑或當前工作路徑目錄。</p></td> </tr></table> **Example 12.1. Appending a local plugin dir 例 12-1.設置一個本地插件路徑** <table border="0" bgcolor="#E0E0E0" width="100%"><tr><td>&lt;?php<br/> $smarty-&gt;plugins_dir[] = 'includes/my_smarty_plugins';<br/> ?&gt;</td> </tr></table> **Example 12.2. Multiple $plugins_dir 例 12-1.多維$plugins_dir** <table border="0" bgcolor="#E0E0E0" width="100%"><tr><td>&lt;?php<br/> $smarty-&gt;plugins_dir = array(<br/>'plugins', // 在SMARTY_DIR目錄下<br/>'/path/to/shared/plugins',<br/>'../../includes/my/plugins'<br/>);<br/>?&gt;</td> </tr></table> # $debugging[調試變量] This enables the debugging console. The console is a javascript popup window that informs you of the included templates, variables assigned from php and config file variables for the current script. It does not show variables assigned within a template with the {assign} function. The console can also be enabled from the url with $debugging_ctrl. See also {debug}, $debug_tpl, and $debugging_ctrl. 本變量用于啟動調試控制臺。該控制臺是一個javascript窗口,向你報告加載模板的腳本中所有php和配置文件變量,但它不會顯示由[{assign}](#)函數加載的內嵌模板分配的變量。 在url中使用[$debugging_ctrl](#)值同樣可以啟動調試控制臺。 參見[{debug}](#)、[$debug_tpl](#)、和[$debugging_ctrl](#)。 # $debug_tpl[調試模板] This is the name of the template file used for the debugging console. By default, it is named debug.tpl and is located in the SMARTY_DIR. See also $debugging and the debugging console section. 本變量設置調試控制臺的模板文件名字。默認情況下,其名字為:debug.tpl,位于Smarty目錄中。 參見[$debugging](#)和[調試控制臺](#)一節。 # $debugging_ctrl[調試控制變量] This allows alternate ways to enable debugging. NONE means no alternate methods are allowed. URL means when the keyword SMARTY_DEBUG is found in the QUERY_STRING, debugging is enabled for that invocation of the script. If $debugging is TRUE, this value is ignored. 本變量允許以交替的方式啟動調試控制。NONE表示不允許交替方式。URL表示當關鍵詞'SMARTY_DEBUG'出現在QUERY_STRING(查詢字符串)中時,此腳本將調用調試控制。如果[$debugging](#)變量設為true,則忽略本調試控制變量。 **Example 12.3. $debugging_ctrl on localhost 例 12-3.設置本地的$debugging_ctrl變量** <table border="0" bgcolor="#E0E0E0" width="100%"><tr><td>&lt;?php<br/> // shows debug console only on localhost ie<br/> // http://localhost/script.php?foo=bar&amp;SMARTY_DEBUG<br/> $smarty-&gt;debugging = false; // the default<br/> $smarty-&gt;debugging_ctrl = ($_SERVER['SERVER_NAME'] == 'localhost') ? 'URL' : 'NONE');<br/> ?&gt;</td> </tr></table> 參見[調試控制](#)一節和[$debugging](#)變量。 # $auto_literal[自動忽略解析] The Smarty delimiter tags { and } will be ignored so long as they are surrounded by white space. This behavior can be disabled by setting auto_literal to false. 只要Smarty定界符標簽‘{’和‘}’內側包含空格,那么模板將忽略定界符里面內容的解析。可以將$auto_literal變量設置為false取消上述規則。 <table border="0" bgcolor="#E0E0E0" width="100%"><tr><td>&lt;?php<br/>$smarty-&gt;auto_literal = false;<br/>?&gt;</td> </tr></table> 參見[忽略Smarty解析](#)一節。 譯注 | 不知將auto_literal翻譯成什么好,反正就是那樣的意思啦~~ | |-----| # $autoload_filters[自動加載過濾器變量] If there are some filters that you wish to load on every template invocation, you can specify them using this variable and Smarty will automatically load them for you. The variable is an associative array where keys are filter types and values are arrays of the filter names. For example: 如果你希望在每次模板調用過程中加載過濾器,你可以使用此變量指定過濾器,Smarty將自動為你加載它們。該變量是一個關聯數組,鍵是過濾器類型,值是過濾器名字所組成的數組。例如: | ~~~ <?php $smarty->autoload_filters = array('pre' => array('trim', 'stamp'),'output' => array('convert')); ?> ~~~ | |-----| 參見[registerFilter()](#)和[loadFilter()](#)函數。 # $compile_check[編譯檢查變量] Upon each invocation of the PHP application, Smarty tests to see if the current template has changed (different time stamp) since the last time it was compiled. If it has changed, it recompiles that template.If the template has not been compiled, it will compile regardless of this setting. By default this variableis set to TRUE. Once an application is put into production (ie the templates won't be changing), the compile check step is no longer needed. Be sure to set $compile_check to FALSE for maximal performance. Note that if you change this to FALSE and a template file is changed, you will *not* see the change since the template will not get recompiled. If $caching is enabled and $compile_check is enabled, then the cache files will get regenerated if an involved template file or config file was updated. See $force_compile and clear_compiled_tpl() . 每次調用PHP應用程序,Smarty會試著查看自上次編譯時間以來,當前模板是否被修改過。如果修改過了,她會重新編譯那個模板。如果模板還沒有被編譯過,她將編譯模板而不管編譯檢查如何設置。默認情況下本編譯檢查變量設置為true。 一旦一個應用程序投入產品中(假如模板將不再修改),就不再需要編譯檢查這一步了。為了獲得最大性能,確定將$compile_check設為"false"。注意:如果設為了"false",雖然模板文件被修改,但你不會看到修改結果,因為模板沒有得到重新編譯。如果啟動了緩存([$caching](#))和編譯檢查($compile_check),一旦有關模板文件或配置文件被更新,緩存文件將會被重建。 參見[$force_compile](#)和[clear_compiled_tpl()](#)。 # $force_compile[強迫編譯變量] This forces Smarty to (re)compile templates on every invocation. This setting overrides $compile_check. By default this is FALSE. This is handy for development and debugging. It should never be used in a production environment. If $caching is enabled, the cache file(s) will be regenerated every time. 每次調用模板時強制Smarty(重新)編譯模板,這項設置會覆蓋[$compile_check](#)變量,使后者的設置失效,默認情況下,本變量為false(假),即Smarty并不強制每次重新編譯模板。它對于開發和調試很方便,但它決不能使用于產品環境下。如果啟動了緩存,每次將會重新生成緩存文件。 譯注 | 本變量設為true的情況一般為開發和調試;因為smarty將模板編譯為php腳本時開銷很大,比純php運行時速度慢10倍以上,甚至是100倍,極大拖慢性能。所以,如果無必要,無須理會本變量。 | |-----| # $caching[緩存變量] This tells Smarty whether or not to cache the output of the templates to the $cache_dir. By default this is set to the constant Smarty::CACHING_OFF. If your templates consistently generate the same content,it is advisable to turn on $caching, as this may result in significant performance gains. You can also have multiple caches for the same template. A constant value of Smarty::CACHING_LIFETIME_CURRENT or Smarty::CACHING_LIFETIME_SAVED enables caching. A value of Smarty::CACHING_LIFETIME_CURRENT tells Smarty to use the current $cache_lifetime variable to determine if the cache has expired. A value of Smarty::CACHING_LIFETIME_SAVED tells Smarty to use the $cache_lifetime value at the time the cache was generated. This way you can set the $cache_lifetime just before fetching the template to have granular control over when that particular cache expires. See also isCached(). If $compile_check is enabled, the cached content will be regenerated if any of the templates or config files that are part of this cache are changed. If $force_compile is enabled, the cached content will always be regenerated. See also $cache_dir, $cache_lifetime, $cache_handler_func,$cache_modified_check, is_cached() and the caching section. 本變量用以告訴Smarty是否緩存模板的輸出,默認情況下,它將常量設置為Smarty::CACHING_OFF,即否。如果模板內容冗余、重復,建議打開緩存,這樣有利于獲得良好的性能增益。 你也可以為同一模板設置多個緩存。 譯注 | 本變量設置有所升級,使用了類靜態常量,請看好說明。 | |-----| Smarty::CACHING_LIFETIME_CURRENT或Smarty::CACHING_LIFETIME_SAVED常量值允許緩存; Smarty::CACHING_LIFETIME_CURRENT常量值告訴Smarty使用當前[$cache_lifetime](#)變量判斷緩存是否過期; 當緩存生成時,常量Smarty::CACHING_LIFETIME_SAVED告訴Smarty使用[$cache_lifetime](#)值;用這種方式可以在獲取模板之前設置緩存生存時間,以便較精確地控制緩存何時失效。參考[isCached()](#)函數; 如果開啟[$compile_check](#)編譯檢查,當模板或配置文件改變時,將會重新生成緩存; 如果開啟[$force_compile](#)強制編譯,每次都重新生成緩存內容; 參見[$cache_dir](#)、[$cache_lifetime](#)、$[cache_handler_func](#)、$[cache_modified_check](#)、[ is_cached()](#)和[緩存](#)一節。 # $cache_dir[緩存目錄變量] This is the name of the directory where template caches are stored. By default this is ./cache, meaning that Smarty will look for the cache/ directory in the same directory as the executing php script. This directory must be writeable by the web server, see install for more info. You can also use your own custom cache handler function to control cache files, which will ignore this setting. See also $use_sub_dirs. 這是存放模板緩存的目錄名,默認情況下為"./cache",也就是說Smarty會在與php執行腳本相同的目錄下尋找緩存目錄。緩存目錄必須可寫,參考[安裝](#)一節。 你也可以用自己的自定義緩存處理函數來控制緩存文件,它將會忽略上述設置。參考[$use_sub_dirs](#)。 <table width="80%" border="0" cellpadding="2" cellspacing="2" class="note"><caption> 技術提示 </caption> <tr><td><b>Technical Note: </b> This setting must be either a relative or absolute path. include_path is not used for writing files.<br/> 本設置必須是一個相對或絕對路徑,包含路徑不可用于寫文件。</td> </tr></table> <table width="80%" border="0" cellpadding="2" cellspacing="2" class="note"><caption> 技術提示 </caption> <tr><td><b>Technical Note: </b> It is not recommended to put this directory under the web server document root.<br/> 不推薦將此目錄放在web服務器根目錄下。</td> </tr></table> 參考[$caching](#)、[$use_sub_dirs](#)、[$cache_lifetime](#)、[$cache_handler_func](#)、[$cache_modified_check](#)和[緩存](#)一節。 # $cache_lifetime[緩存生存時間變量] This is the length of time in seconds that a template cache is valid. Once this time has expired, the cache will be regenerated. $caching must be turned on (either SMARTY_CACHING_LIFETIME_CURRENT or SMARTY_CACHING_LIFETIME_SAVED) for $cache_lifetime to have any purpose. A value of -1 will force the cache to never expire. A value of 0 will cause the cache to always regenerate (good for testing only, to disable caching a more efficient method is to set [$caching](#) = SMARTY_CACHING_OFF). If you want to give certain templates their own cache lifetime, you could do this by setting $caching=SMARTY_CACHING_LIFETIME_SAVED, then set $cache_lifetime to a unique value just before calling display() or fetch(). If $force_compile is enabled, the cache files will be regenerated every time, effectively disabling caching. You can clear all the cache files with the clear_all_cache() function, or individual cache files (or groups) with the clear_cache() function. 本變量定義模板緩存有效時間(單位秒),一旦這個時間失效,則緩存將會重新生成。 使用$cache_lifetime前必須先開啟[$caching](#)(可以設置SMARTY_CACHING_LIFETIME_CURRENT或SMARTY_CACHING_LIFETIME_SAVED); 本變量值設為-1時,將強迫緩存永不過期; 0值將導致緩存總是重新生成(僅有利于測試,一個更有效的使緩存無效的方法是設置[$caching](#) = false) ; 如果你需要為每個模板設置自己的緩存有效時間,可以使用$caching=SMARTY_CACHING_LIFETIME_SAVED,然后再調用[display()](#)或[fetch()](#)函數前設置$caching_lifetime為唯一值。 如果啟動了強迫編譯[$force_compile](#),則緩存文件每次將會重新生成。要想有效地停止緩存,你可以利用[clear_all_cache()](#) 函數清除所有的緩存文件,或者利用[clear_cache()](#) 函數清除個別文件(或文件組)。 # $cache_handler_func[緩存處理函數變量] You can supply a custom function to handle cache files instead of using the built-in method using the $cache_dir. See the custom cache handler function section for details. 你可以提供一個自定義函數來處理緩存文件,而不通過變量[$cache_dir](#)使用Smarty內置方法。詳見:[緩存處理函數](#)一節。 # $cache_modified_check[緩存修改檢查變量] If set to true, Smarty will respect the If-Modified-Since header sent from the client. If the cached file timestamp has not changed since the last visit, then a "304 Not Modified" header will be sent instead of the content. This works only on cached content without {insert} tags. 如果設置該變量為真,Smarty將分析客戶端發送來的If-Modified-Since頭信息。如果緩存文件時間戳自上次訪問以來沒有改變,則發送一個"304 Not Modified"頭,而不是緩存文件內容。這種方式僅工作于沒有[{insert}](#)標記的緩存內容。 # $config_overwrite[配置.覆蓋變量] If set to TRUE, the default then variables read in from config files will overwrite each other. Otherwise,the variables will be pushed onto an array. This is helpful if you want to store arrays of data in config files,just list each element multiple times. 如果本變量設為真,則從配置文件中讀取出來的變量將會互相覆蓋,否則,變量將會去堆壓到一個數組中。如果你想把配置文件中的數據存儲到數組里,這種方式是很有用的,可以多次列出里面的元素(見下例)。默認情況下,設為真。 **Example 12.4. Array of config #variables# 例 12-4.配置文件變量****數組** <table border="0" bgcolor="#E0E0E0" width="100%"><tr><td><p>This examples uses {cycle} to output a table with alternating red/green/blue row colors with $config_overwrite = FALSE.<br/> 本例設置$config_overwrite = FALSE,使用{cycle}輸出交替顯示紅/綠/藍行顏色的表格。</p> <p><br/> The config file.</p> <p> # row colors<br/> rowColors = #FF0000<br/> rowColors = #00FF00<br/> rowColors = #0000FF<br/><br/> The template with a {section} loop.</p> <p><br/> &lt;table&gt;<br/> {section name=r loop=$rows}<br/> &lt;tr bgcolor="{cycle values=#rowColors#}"&gt;<br/> &lt;td&gt; ....etc.... &lt;/td&gt;<br/> &lt;/tr&gt;<br/> {/section}<br/> &lt;/table&gt;</p></td> </tr></table> 參見[{config_load}](#)、[get_config_vars()](#)、[clear_config()](#)、[config_load()](#)和[配置文件](#)一節。 # $config_booleanize[配置.布爾型變量] If set to TRUE, config files values of on/true/yes and off/false/no get converted to boolean values automatically. This way you can use the values in the template like so: {if #foobar#}...{/if}. If foobar was on, true or yes, the {if} statement will execute. Defaults to TRUE. 如果本變量設為真,配置文件中的on/true/yes和off/false/no值會自動轉化為布爾值。這樣的話,你就可以在模板中像{if #foobar#} ... {/if}這樣使用上述符合布爾類型的值了。如果foobar為on、true或yes,那么 {if}語句就會執行了。默認情況下,該變量值為真。 # $config_read_hidden[配置.讀取隱藏變量] If set to true, hidden sections (section names beginning with a period) in config files can be read from templates. Typically you would leave this false, that way you can store sensitive data in the config files such as database parameters and not worry about the template loading them. false by default. 如果設本變量為真,可以從模版中讀取在配置文件中的隱藏節塊(以英文句號/句點開頭的節塊,見[配置文件](#)一節)。一般情況下,你會保留本變量為假,這樣你可以在配置文件里存放敏感數據,例如數據庫參數,而不用擔心模版會將它們調用出來。默認情況下,本變量設為假。 # $config_fix_newlines[配置.固定換行符變量] If set to TRUE, mac and dos newlines ie '\r' and '\r\n' in config files are converted to '\n' when they are parsed. Default is TRUE. 如果本變量設為真,那么在配置文件中的mac和dos換行符(即\r和\r\n)在語法解析時將會轉換為\n。默認情況下,該變量為真。 # $default_template_handler_func[默認模板處理函數變量] This function is called when a template cannot be obtained from its resource. 該函數在不能從模板的源目錄下獲取模板時會得到調用。 # $php_handling[php處理變量] This tells Smarty how to handle PHP code embedded in the templates. There are four possible settings,the default being Smarty::PHP_PASSTHRU. Note that this does NOT affect php code within {php}{/php} tags in the template. - Smarty::PHP_PASSTHRU - Smarty echos tags as-is. - Smarty::PHP_QUOTE - Smarty quotes the tags as html entities. - Smarty::PHP_REMOVE - Smarty removes the tags from the templates. - Smarty::PHP_ALLOW - Smarty will execute the tags as PHP code. 該變量告訴Smarty怎樣處理嵌入到模版中的php代碼。有四種可能的設置,默認為Smarty::PHP_PASSTHRU。注意,本變量的設置不會影響模板里面{php}{/php}標記中的php代碼。 Smarty::PHP_PASSTHRU--原樣輸出標記 Smarty::PHP_QUOTE--作為html實體引用標記 Smarty::PHP_REMOVE--從模板中移出標記 Smarty::PHP_ALLOW --將作為php代碼執行標記 <table width="80%" border="0" cellpadding="2" cellspacing="2" class="note"><caption> 提示 </caption> <tr><td>NOTE: Embedding PHP code into templates is highly discouraged. Use <a href="language.custom.functions.html">custom functions</a> or <a href="language.modifiers.html">modifiers</a> instead.<br/> 極度不贊成將php代碼嵌入到模板中,建議改用<a href="language.custom.functions.html">自定義函數</a>或<a href="language.modifiers.html">調節器</a>。</td> </tr></table> # $trusted_dir[信任目錄變量] $trusted_dir is only for use when $security is enabled. This is an array of all directories that are considered trusted. Trusted directories are where you keep php scripts that are executed directly from the templates with [{include_php}](#). $trusted_dir僅用在$security啟動之后。本變量是一個數組,它包含所有被認為能信任的目錄。你可以將php腳本放到這些受信任目錄中,這些腳本會直接在模板里以[{include_php}](#)標記得到執行。 # $left_delimiter[左定界符變量] This is the left delimiter used by the template language. Default is "{". See also $right_delimiter and escaping smarty parsing . 本變量定義模板中的左定界符,默認為"{"。 參見[$right_delimiter](#)和[忽略smarty解析](#)。 # $right_delimiter[右定界符變量] This is the right delimiter used by the template language. Default is "}". See also $left_delimiter and escaping smarty parsing. 本變量定義模板中的右定界符,默認為"}"。 參見[$left_delimiter](#)和[忽略smarty解析](#)。 # $compiler_class[編譯類變量] Specifies the name of the compiler class that Smarty will use to compile the templates. The default is 'Smarty_Compiler'. For advanced users only. 本變量用以指定Smarty編譯模板的編譯類名,默認為:'Smarty_Compiler'。僅適合于高級用戶。 # $request_vars_order[變量順序變量] The order in which request variables are registered, similar to variables_order in php.ini See also $smarty.request and $request_use_auto_globals. 本變量用以配置注冊的請求變量順序,類似于php.ini中的variables_order。 參見[$smarty.request](#)和[$request_use_auto_globals](#)。 # $request_use_auto_globals[自動全局變量] Specifies if Smarty should use PHP's $HTTP_*_VARS[] when FALSE or $_*[] when TRUE which is the default value. This affects templates that make use of {$smarty.request.*}, {$smarty.get.*} etc. 本變量指定Smarty是否使用php的$HTTP_*_VARS[]數組變量(默認$request_use_auto_globals=false)或$_*[]數組($request_use_auto_globals=true)變量。這對使用了{$smarty.request.*}、{$smarty.get.*}等標記的模板有影響。 <table width="80%" border="0" cellpadding="2" cellspacing="2" class="warning"><caption> 警告 </caption> <tr><td>Caution<br/> If you set $request_use_auto_globals to true, $request_vars_order has no effect but PHP's configuration value gpc_order is used.<br/> 如果設置$request_use_auto_globals為真,<a href="#request_vars_order">$request_vars_order</a>就無效了,但php的gpc_order配置值還有作用。</td> </tr></table> 譯注 | $HTTP_*_VARS[]已在php5中棄用,改而使用$_*[]超全局變量,請注意自己的php版本。 | |-----| # $compile_id[編譯id變量] Persistant compile identifier. As an alternative to passing the same $compile_id to each and every function call, you can set this $compile_id and it will be used implicitly thereafter. With a $compile_id you can work around the limitation that you cannot use the same $compile_dir for different $template_dirs. If you set a distinct $compile_id for each $template_dir then Smarty can tell the compiled templates apart by their $compile_id. If you have for example a prefilter that localizes your templates (that is: translates language depend parts) at compile time, then you could use the current language as $compile_id and you will get a set of compiled templates for each language you use. Another application would be to use the same compile directory across multiple domains / multiple virtual hosts. 本變量是個固定的編譯標識。作為一個可選辦法將相同的編譯標識傳遞給每個函數調用,你可以設置這個編譯id,此id將會在后臺暗中被調用。 編譯id的使用限定了工作范圍,同一編譯id不能對應不同的[$template_dirs](#)模板地址。如果為一個$template_dirs設置不同的編譯id,那么Smarty會依$compile_id將這些編譯模板區分開。 假如,你有一個預過濾器在編譯時本地化你的模板(翻譯的語言取決于所在地區),那么你可以使用當前語言作為$compile_id,這樣你就得到了一套依語言分類的編譯模板。 本變量的另一應用是使用多個域名/多個虛擬主機訪問同一編譯目錄。 **Example 12.5. $compile_id in a virtual host environment 例 12-4.$compile_id****在虛擬主機環境的設置** <table border="0" bgcolor="#E0E0E0" width="100%"><tr><td>&lt;?php<br/> $smarty-&gt;compile_id = $_SERVER['SERVER_NAME'];<br/> $smarty-&gt;compile_dir = '/path/to/shared_compile_dir';<br/> ?&gt;</td> </tr></table> # $use_sub_dirs[子目錄變量] Smarty will create subdirectories under the compiled templates and cache directories if $use_sub_dirs is set to TRUE, default is FALSE. In an environment where there are potentially tens of thousands of files created, this may help the filesystem speed. On the other hand, some environments do not allow PHP processes to create directories, so this must be disabled which is the default. Sub directories are more efficient, so use them if you can. Theoretically you get much better perfomance on a filesystem with 10 directories each having 100 files, than with 1 directory having 1000 files. This was certainly the case with Solaris 7 (UFS)... with newer filesystems such as ext3 and especially reiserfs,the difference is almost nothing. 如果$use_sub_dirs變量設為真,Smarty將會在編譯模板和緩存目錄下創建子目錄,默認為假。在擁有成千上萬的文件環境中,本變量為真可以加速你的文件系統。另一方面,存在一些服務器環境下不允許php進程建立目錄的情況,那么,就保持此變量為假。 子目錄非常有效,因此,盡可能使用它吧。理論上來說,在一個文件系統中,10個目錄分別放置100個文件比1個目錄放置1000個文件的性能要好。當然這是Solaris 7操作系統的情況...在新的文件系統中,如ext3,尤其是ReiserFS文件系統,這種差別可以忽略不計。 <table width="80%" border="0" cellpadding="2" cellspacing="2" class="note"><caption> 技術提示 </caption> <tr><td><p>Technical Note </p><li>$use_sub_dirs=true doesn't work with safe_mode=On [http://php.net/features.safe-mode], that's why it's switchable and why it's off by default.</li> <li> $use_sub_dirs=true on Windows can cause problems.</li> <li> Safe_mode is being deprecated in PHP6.</li> <br/><li>當Smarty工作在php安全模式時(safe_mode=on),$use_sub_dirs=true將失效,這就是為什么本變量須設切換開關和默認為關閉的原因;</li> <li> 在windows系統中,$use_sub_dirs=true會出錯;</li> <li> 安全模式在php6中已被棄用。</li></td> </tr></table> 參見[$compile_id](#)、[$cache_dir](#)和[$compile_dir](#)。 # $default_modifiers[默認調節器變量] This is an array of modifiers to implicitly apply to every variable in a template. For example, to HTML-escape every variable by default, use array('escape:"htmlall"'). To make a variable exempt from default modifiers, pass the special smarty modifier with a parameter value of nodefaults modifier to it, such as {$var|smarty:nodefaults}. 本變量是個調節器數組,它隱式作用于模板中的每個變量,例如,默認為HTML轉義每個變量,可用數組('escape:"htmlall"')。如果不使用默認調節器,可傳遞其它smarty調節器給本變量,調節器名后須帶一個參數值“nodefaults”,例如,{$var|smarty:nodefaults}。 # $default_resource_type[默認源類型變量] This tells smarty what resource type to use implicitly. The default value is 'file', meaning that $smarty->display('index.tpl'); and $smarty->display('file:index.tpl'); are identical in meaning. See the [resource](#) chapter for details. 本變量告訴smarty隱式地使用什么資源類型。默認值為'file',也就是說,$smarty->display('index.tpl')和$smarty->display('file:index.tpl')從意思上是一樣的。 參見[resource資源](#)一章。 <table width="100%" summary="Footer navigation table" border="0" cellpadding="0" cellspacing="0"><tr><td width="33%" align="left" valign="top"><a accesskey="P" href="smarty.constants.html">Prev</a></td><td width="34%" align="center"><a accesskey="H" href="index.html">Home</a></td><td width="33%" align="right" valign="top"> <a href="api.functions.html">Next</a></td></tr><tr><td width="33%" align="left" valign="top">SMARTY_DIR<br/> Smarty 目錄</td><td width="34%" align="center"><a accesskey="U" href="smarty.for.programmers.html">Up</a></td><td width="33%" align="right" valign="top">Smarty Class Methods()<br/> Smarty類方法</td></tr></table>
                  <ruby id="bdb3f"></ruby>

                  <p id="bdb3f"><cite id="bdb3f"></cite></p>

                    <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
                      <p id="bdb3f"><cite id="bdb3f"></cite></p>

                        <pre id="bdb3f"></pre>
                        <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

                        <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
                        <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

                        <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                              <ruby id="bdb3f"></ruby>

                              哎呀哎呀视频在线观看