对象的简单使用
对象的声明和变量一样,通过assign来声明
修改test.php文件:
<?php
require "./libs/Smarty.class.php";
$smarty = new Smarty;
class Person{
public $name="smile";
public $age=25;
}
$person=new Person();
$smarty->assign('address',$person);
$smarty->display('./templates/test.html');修改test.html文件:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>test</title>
</head>
<body>
<!--html的注释-->
{*smarty模板的注释*}
我叫{$address->name}今年{$address->age}岁<br>
</body>
</html>运行展示如下:

