createTemplate()
返回一个模板对象
说明
Smarty_Internal_Template
createTemplate
字符串
模板
对象
父级
Smarty_Internal_Template
createTemplate
字符串
模板
数组
数据
Smarty_Internal_Template
createTemplate
字符串
模板
字符串
缓存 ID
字符串
编译 ID
对象
父级
Smarty_Internal_Template
createTemplate
字符串
模板
字符串
缓存 ID
字符串
编译 ID
数组
数据
这将创建一个模板对象,该对象稍后可以通过 display 或 fetch 方法进行渲染。它使用以下参数
template
必须是一个有效的 模板资源 类型和路径。
<?php
use Smarty\Smarty;
$smarty = new Smarty;
// create template object with its private variable scope
$tpl = $smarty->createTemplate('index.tpl');
// assign variable to template scope
$tpl->assign('foo','bar');
// display the template
$tpl->display();
?>
另请参阅 display()
和 templateExists()
。