createTemplate()
返回一个模板对象
描述
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
这将创建一个模板对象,稍后可以通过 display 或 fetch 方法进行渲染。它使用以下参数:
template必须是有效的 模板资源 类型和路径。
<?php
include('Smarty.class.php');
$smarty = new Smarty;
// 创建具有其私有变量范围的模板对象
$tpl = $smarty->createTemplate('index.tpl');
// 将变量分配给模板范围
$tpl->assign('foo','bar');
// 显示模板
$tpl->display();
?>
参见 display(),和
templateExists()。