输出过滤器将处�模�的输出内容, 执行的时机是在模�载入并执行之�,但在内容显示之�。
string smarty_outputfilter_name( |
$template_output, | Â |
| Â |
$template); |
 |
string $template_output;object $template;第一个�数是将会被处�的输出内容, 第二个�数是调用该函数的Smarty实例。 �件会对内容进行处�并返回结果。
Example 18.9. 输出过滤器
<?php
/*
* Smarty plugin
* -------------------------------------------------------------
* File: outputfilter.protect_email.php
* Type: outputfilter
* Name: protect_email
* Purpose: 将邮件地å�€çš„@转æ�¢æˆ�%40,以防æ¢åžƒåœ¾é‚®ä»¶çˆ¬è™«çš„æ”¶é›†ã€‚
* -------------------------------------------------------------
*/
function smarty_outputfilter_protect_email($output, Smarty_Internal_Template $template)
{
return preg_replace('!(\S+)@([a-zA-Z0-9\.\-]+\.([a-zA-Z]{2,3}|[0-9]{1,3}))!',
'$1%40$2', $output);
}
?>
��:
registerFilter(),
unregisterFilter().
