W3Cschool
恭喜您成為首批注冊(cè)用戶
獲得88經(jīng)驗(yàn)值獎(jiǎng)勵(lì)
createTemplate() — 創(chuàng)建模板對(duì)象
Smarty_Internal_Template createTemplate(string template,
object parent);
Smarty_Internal_Template createTemplate(string template,
array data);
Smarty_Internal_Template createTemplate(string template,
string cache_id,
string compile_id,
object parent);
Smarty_Internal_Template createTemplate(string template,
string cache_id,
string compile_id,
array data);
創(chuàng)建一個(gè)模板對(duì)象,可以讓display或者fetch來使用。 參數(shù)如下:
template
必須是 模板資源類型和路徑。
cache_id
is an optional parameter. You can also set the $cache_id
variable once instead of passing this to each call to this function. It is used in the event that you want to cache different content of the same template, such as pages for displaying different products. See also the caching section for more information.
compile_id
is an optional parameter. You can also set the $compile_id
variable once instead of passing this to each call to this function. It is used in the event that you want to compile different versions of the same template, such as having separate templates compiled for different languages.
parent
is an optional parameter. It is an uplink to the main Smarty object, a user-created data object or to another user-created template object. These objects can be chained. The template can access only variables assigned to any of the objects in the parent chain.
data
is an optional parameter. It is an associative array containing the name/value pairs of variables which get assigned to the object.
Example 14.18. createTemplate()
<?php include('Smarty.class.php'); $smarty = new Smarty; // 創(chuàng)建模板對(duì)象 $tpl = $smarty->createTemplate('index.tpl'); // 賦值 $tpl->assign('foo','bar'); // 顯示模板 $tpl->display(); ?>
參見 display()
, 和 templateExists()
.
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)系方式:
更多建議: