smarty类与对象的赋值与使用

<?php
require_once('../smarty/Smarty.class.php');

//配置信息
$smarty=new Smarty();

$smarty->left_delimiter="{";
$smarty->right_delimiter="}";
$smarty->template_dir="tpl";
$smarty->compile_dir="template_c";
$smarty->cache_dir="cache";

$smarty->caching=true;
$smarty->cache_lifetime=120;

class my_object{

function meth1($param){

return $param[0].'已经'.$param[1];
}
}
$myobj=new my_object();
$smarty->assign('myobj',$myobj);
$smarty->display("test.html");

?>
//********test.html*******************
<!doctype html>
<html>
<meta charset="utf-8">
<head></head>
<body>
<!--以数组形式-->
{$myobj->meth1(array('苹果','熟了'))}
</body>
</html>

posted @ 2016-08-04 11:25  blogging  阅读(346)  评论(0编辑  收藏  举报