<?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>
时间: 2024-11-05 23:21:13