Get Smarty


Smarty Icon

You may use the Smarty logo according to the trademark notice.

Smarty Template Engine Smarty Template Engine

For sponsorship, advertising, news or other inquiries, contact us at:

Sites Using Smarty

Buy cheap glasses from and save up to 80%.

Where to buy prescription glasses? is your best choice!

Where to buy discount wedding dresses and cheap smart dresses free shipping -

Shop for 2018 World Cup Football Boots Online sale at

Browse best 2018 world cup soccer cleats and shoes from



当通过display()fetch()来调用模板的时候, 输出的内容将会经过一个或者多个输出过滤器来进行处理。 对比 后置过滤器, 后置过滤器是在模板编译后但没有被存储到编译文件前调用, 输出过滤器是模板执行后准备输出时调用。

输出过滤器可以通过注册过滤器来调用, 或者放置到插件目录中,用 loadFilter()函数或者 设置 $autoload_filters来调用。 Smarty把准备输出的内容作为第一个参数传递到函数中,并期待函数返回经过处理的内容。

Example 17.13. 使用输出过滤器

// 在PHP程序中
function protect_email($tpl_output, Smarty_Internal_Template $template)
    $tpl_output =
                    '$1%40$2', $tpl_output);
    return $tpl_output;

// 注册过滤器

// 现在,所有显示的电子邮件地址都会经过简单保护,以防止垃圾邮件爬虫


参见 registerFilter(), loadFilter(), $autoload_filters, 后置过滤器$plugins_dir.

No comments for this page.
Post a Comment
All comments are moderated. Support questions are ignored, use the forums instead.
Email: (not shown)
What is 11 plus 8? (Are you human?)