Get Smarty

Donate

Donate Bitcoin Bitcoin
Paypal

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 eyeglasses from Cheapglasses123.com and save up to 80%.

Buy prescription glasses from www.australiaglasses.com and save.

Cheap Glasses Now On Sale at GlassesPeople.com. Starts At $7.95.

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

Brautkleider auf Topwedding.de

Find free files to download on allwhatyouwant.net

Looking For Affordable Wedding Dresses 2015 at Best Prices On TDBridal.com

Shop high quality cheap prom dresses on Dresswe.co.uk

Buy New Arrival Cheap Prom Dresses 2015 at JDBRIDAL Prom Dress Store

Advertisement

输出过滤器

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

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

Example 17.13. 使用输出过滤器


<?php
// 在PHP程�中
function protect_email($tpl_output, Smarty_Internal_Template $template)
{
    $tpl_output =
       preg_replace('!(\S+)@([a-zA-Z0-9\.\-]+\.([a-zA-Z]{2,3}|[0-9]{1,3}))!',
                    '$1%40$2', $tpl_output);
    return $tpl_output;
}

// 注册过滤器
$smarty->registerFilter("output","protect_email");
$smarty->display("index.tpl");

// 现在,所有显示的电�邮件地�都会�过简��护,以防止垃圾邮件爬虫
?>

    

�� registerFilter(), loadFilter(), $autoload_filters, �置过滤器 和 $plugins_dir.

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

Advertisement