(1) Baoliu.php
<?php
include "libs/Smarty.class.php";
$array=array("张三","李斯","王五","赵六","四通","小杜","机场","省事","找死","欠揍");
setcookie("name","zhansanfeng");
$smarty= new Smarty();
$smarty->template_dir="demo1/templates";
$smarty->compile_dir="demo1/templates_c";
$smarty->config_dir="demo1/config";
$smarty->config_dir="demo1/templates";
$smarty->left_delimiter="<{";//界定符
$smarty->right_delimiter="}>";
$smarty->assign("a",$array);
$smarty->display("baoliu.tpl");
?>
(2) baoliu.tpl
<{config_loadfile="if.conf"}>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN""http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<htmlxmlns="http://www.w3.org/1999/xhtml">
<head>
<metahttp-equiv="Content-Type" content="text/html;charset=utf-8" />
<title>无标题文档</title>
</head>
<body bgcolor=<{#bgColor#}>>
<{section name=a loop=$a}>
第<{$smarty.section.a.iteration}>个人是<{$a[a]}><br />
<{/section}>
总共有<{$smarty.section.a.total}>个人
<{foreach from=$a item=value}>
<{$value}><br />
<{/foreach}>
<{$smarty.get.a}><br />
<{$smarty.cookies.name}>
</body>
</html>
(3)
If.cong
bgColor=#00cc33