$smarty->register_function('dateline', 'handle_dateline');
dateline 是在模板里使用的名字
如
{dateline time="$time" format="Y-m-d"}
而不是
{handle_dateline time="$time" format="Y-m-d"}
呵呵,自己找罪受function handle_dateline($params, &$smarty) {}
$params 传入的参数数组,比如上例中就有两个元素
函数体你可能会这样写
extract($params);
echo date($format,$time);$smarty smarty 对象本身,因为你有可能需要在函数体内访问 $smarty 的属性和方法
dateline 是在模板里使用的名字
如
{dateline time="$time" format="Y-m-d"}
而不是
{handle_dateline time="$time" format="Y-m-d"}
呵呵,自己找罪受function handle_dateline($params, &$smarty) {}
$params 传入的参数数组,比如上例中就有两个元素
函数体你可能会这样写
extract($params);
echo date($format,$time);$smarty smarty 对象本身,因为你有可能需要在函数体内访问 $smarty 的属性和方法
$smarty->register_function('dateline', 'handle_dateline');
并没有传递任何参数给function handle_dateline($params, &$smarty) {}??
注册函数上面的语句,会不会导致函数 “function handle_dateline($params, &$smarty) {} ” 执行?