smarty3不再支持register_function,不过可以使用新的函数:registerPlugin
void registerPlugin(string type,
string name,
mixed callback,
bool cacheable,
mixed cache_attrs);
<?php
$smarty->registerPlugin("function","date_now", "print_current_date");
function print_current_date($params, $smarty){
if(empty($params["format"])) { $format = "%b %e, %Y"; } else { $format = $params["format"]; } return strftime($format,time());
}
?>
templates.html
{date_now} {* or to format differently *} {date_now format="%Y/%m/%d"}