display

PHP Smarty

Smarty - the compiling PHP template engine
Prev 来源:PHP中文社区 Chapter 13. Methods Next

display
显示

include("Smarty.class.php");
$smarty = new Smarty;
$smarty->caching = true;

// only do db calls if cache doesn't exist
// 只有在缓存不存在时才调用数据库
if(!$smarty->is_cached("index.tpl"))
{

// dummy up some data
$address = "245 N 50th";
$db_data = array(
"City" => "Lincoln",
"State" => "Nebraska",
"Zip" = > "68502"
);

$smarty->assign("Name","Fred");
$smarty->assign("Address",$address);
$smarty->assign($db_data);

}

// display the output
// 显示输出
$smarty->display("index.tpl");
// absolute filepath
// 绝对路径
$smarty->display("/usr/local/include/templates/header.tpl");

// absolute filepath (same thing)
// 绝对路径(另外一种方式)
$smarty->display("file:/usr/local/include/templates/header.tpl");

// windows absolute filepath (MUST use "file:" prefix)
// WINDOS平台下的绝对路径(必须使用“file:”前缀)
$smarty->display("file:C:/www/pub/templates/header.tpl");

// include from template resource named "db"
// 从模板资源“db“中调用
$smarty->display("db:header.tpl");

Prev 来源:PHP中文社区 Home Next
config_load
加载配置
Up fetch
取得输出的内容