请教各位大侠一个smarty的问题
如题,下面是源代码:
index.php:
assign(time,date(y-m-d h-i-s));
class user{
function smarty_function_myname($param,&$smarty) {
if (isset($param['name'])) {
if (xxx==$param['name']) {
return 我认识.
}else {
return 我不认识你!;
}
}
}
}
$user = new user();
$sm->register_function(myname, array($user,smarty_function_myname));
$sm->display(index.tpl);
?>
--------------------------------------------------------------------
index.tpl:
insert title here
----------------------------------------------------
为什么访问index.php的时候一直报错,错误如下:
fatal error: call to undefined function smarty_function_myname() in f:\appserv\www\demo\templates_c\%%45^45e^45e480cd%%index.tpl.php on line 12
ps:要是将index.php换成如下,可以正常使用:
register_function(myname, smarty_function_myname);
$sm->display(index.tpl);
?>
求高手指教...
------解决方案--------------------
不懂~~都是用php处理,用smarty显示而已~
array(&$object, $method)数组形式,其中&$object是一个对象的引用,而$method是它的一个方法;
会不会是$sm->register_function(myname, array(&$user,smarty_function_myname));呢?