registerPlugin函数,该函数的原型为
void registerPlugin(string type,
string name,
mixed callback,
bool cacheable,
mixed cache_attrs);
function htmlcode($paras) {
extract($paras);
Return str_replace('/n/r','
',str_replace(' ',' ',$cont));
}
$smarty=new Smarty();
$smarty->registerPlugin('function','format_content','htmlcode');
$smarty->display("list.html");
//list.html
{section name=reply loop=$content}
标题:{$content[reply].title} 用户:{$content[reply].user}内容:{format_content cont=$content[reply].content}{/section}