smarty可以将对象传递到模板,然后在模板像php那样使用

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>