——————————————————————————————————————————————————————————————————
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title><{$name}>的主页</title>
</head>
<body bgcolor="#990000">
————————————
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>无标题文档</title>
</head>
<body>
<{if $dq=='left'}>
<span style="float:left"><{$text}></span>
<{elseif $dq=='right'}>
<span style="float:right"><{$text}></span>
<{else}>
<center><{$text}></center>
<{/if}>
</body>
</html>
————————————
<{include file = "header.tpl"}>
nishi <br />
woshi <br />
归属地:
<select>
<option><{$arr[0]}></option>
<option><{$arr[1]}></option>
<option><{$arr[2]}></option>
</select><br>
出生年月:
<{$birthday.year}>年<{$birthday.month}>月<{$birthday.day[0]}>日 <{$birthday.day[1]}><br>
我是<{$student->name}>,<{$student->sex}>,
年龄<{$student->age}><br>
我的宣言是<{$student->study()}><br>
<{include file = "foot.tpl"}>
——————————————————————————————————————下为php文件——————————————————————
<?php
$address = array('河北','河南','河西');
$birthday = array("year"=>'1990',"month"=>'12',"day"=>array('1','星期一'));
class Stu{
var $name;
var $sex;
var $age;
function study(){
echo "好好学习,天天向上";
}
}
$stu1 = new Stu;
$stu1->name="张三";
$stu1->sex="男";
$stu1->age=15;
include ("libs/Smarty.class.php");
$smarty = new Smarty();
$smarty->template_dir = "demo/templates";
$smarty->compile_dir = "demo/templates_c";
$smarty->left_delimiter = "<{";
$smarty->right_delimiter = "}>";
$smarty->assign("name","李武");
$smarty->assign("arr",$address);
$smarty->assign("birthday",$birthday);
$smarty->assign("student",$stu1);
$smarty->display("test.tpl");
?>