设为首页 收藏本站
查看: 715|回复: 0

[经验分享] PHP-Smarty模板引擎-翻译-手册-第15章高级特性-输出过滤器

[复制链接]

尚未签到

发表于 2017-4-8 09:59:56 | 显示全部楼层 |阅读模式
PHP-Smarty模板引擎-翻译-手册-第15章高级特性-输出过滤器
Output Filters
输出过滤器
  When the template is invoked via display()or fetch(), its output can be sent through one or more output filters. This differs frompostfiltersbecause postfilters operate on compiled templates before they are saved to the disk, whereas output filters operate on thetemplate output when it is executed.
  通过display()或fetch()执行模板时,输出可以被发送到一个或多个输出过滤器,与postfilters不同,postfilters在已编译的模板保存在硬盘前处理,而输出过滤器在模板执行后处理输出。
  Output filterscan be either registeredor loaded from the plugins directoryby using the load_filter()method or by setting the  $autoload_filtersvariable. Smarty will pass the template output as the first argument, and expect the function to return the result of the processing.
  输出过滤器可以通过注册,也可以使用load_filter()方法或设置$autoload_filters变量从pluginsdirectory中加载。Smarty将把模板输出传递为第一个参数,然后获取函数处理后的结果。
  Example 15-4. Using a template outputfilter
  例15-4. 使用模板输出过滤器

<?php
// put this inyour application
// 把下列代码放入你的应用程序中
functionprotect_email($tpl_output, &$smarty)
{
$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;
}

// register the outputfilter
// 注册输出过滤器
$smarty->register_outputfilter('protect_email');
$smarty->display('index.tpl');

// now any occurrence of an email address in the template output will have
// a simple protection against spambots
// 现在模板输出中出现的任何电子邮件地址都拥有针对垃圾邮件机器人的简单保护
?>

  See also register_outpurfilter(),load_filter(),$autoload_filters,postfiltersand $plugins_dir.
  参考 register_outpurfilter(),load_filter(),$autoload_filters,postfiltersand $plugins_dir.
[PHP- Smarty模板引擎 - Manual手册 - Chapter 15. Advanced Features第15章高级特性 - Output Filters输出过滤器]
  http://www.smarty.net/manual/en/advanced.features.outputfilters.php
PHP - Smarty 模板引擎 - Blog
[PHP - Smarty模板引擎 -官方网站]
  http://www.smarty.net/
[PHP - Smarty模板引擎 - 下载地址]
  当前版本 2.6.25, http://www.smarty.net/do_download.php?download_file=Smarty-2.6.25.tar.gz
  全部列表, http://smarty.php.net/download.php
[PHP - Smarty模板引擎 - 相关论坛]
  http://php.board.newsmth.net/
http://forum.csdn.net/SList/PHP/
http://www.phpinsider.com/smarty-forum/
http://news.php.net/php.smarty.general
http://news.php.net/php.smarty.dev
http://news.php.net/php.smarty.cvs

[PHP - Smarty模板引擎 - 关键词]
  smarty
[PHP - Smarty模板引擎 - Manual手册 - Chapter 3. Basic Syntax第3章 基础语法]
  [9]翻译, Comments注释, http://smarty.php.net/manual/en/language.basic.syntax.php#language.syntax.comments[4]
Math 数学运算, http://smarty.php.net/manual/en/language.math.php[7]

[PHP - Smarty模板引擎 - Manual手册 - Chapter 5. Variable Modifiers第5章 变量修饰符]
  cat将值连接到给定变量之后, http://smarty.php.net/manual/en/language.modifier.cat.php[6]
  escape转义修饰符, http://smarty.php.net/manual/en/language.modifier.escape.php[10]
  upper将字符串转换成大写字母, http://smarty.php.net/manual/en/language.modifier.upper.php[4]
[PHP - Smarty模板引擎 - Manual手册 - Chapter 7. Built-in Functions第7章 内建函数]
{config_load}用于从一个配置文件加载配置变量到模板中, http://www.smarty.net/manual/en/language.builtin.functions.php

  {foreach},{foreachelse}用于像访问序数数组一样访问关联数组, http://smarty.php.net/manual/en/language.function.foreach.php[8]

  {strip}在显示之前删除每行前后多余的空格和回车字符, http://smarty.php.net/manual/en/language.function.strip.php[1]
[PHP - Smarty模板引擎 - Manual手册 - Chapter 8. Custom Functions第8章 自定义函数]
  {assign}用于在模板执行过程中设置模板变量, http://smarty.php.net/manual/en/language.custom.functions.php#language.function.assign
  {counter}计数器, http://smarty.php.net/manual/en/language.custom.functions.php
  借助cycle实现循环输出值, http://smarty.php.net/manual/en/language.function.cycle.php[25]

[PHP - Smarty模板引擎 - Manual手册 - Chapter 12. Smarty Class Variables第十二章Smarty类变量]
  $plugins_dir插件文件夹,http://smarty.net/manual/en/variable.plugins.dir.php[35]
[PHP - Smarty模板引擎 - Manual手册 - 第13章 Smarty类方法]
  assign_by_ref()按引用赋值, http://smarty.php.net/manual/en/api.assign.by.ref.php[16]
register_function()动态注册模板函数插件, http://smarty.php.net/manual/en/api.register.function.php[26]
[PHP- Smarty 模板引擎 - 翻译 - Manual手册 - Chapter 15. Advanced Features第15章 高级特性]
  OutputFilters输出过滤器, http://www.smarty.net/manual/en/advanced.features.outputfilters.php[27]

运维网声明 1、欢迎大家加入本站运维交流群:群②:261659950 群⑤:202807635 群⑦870801961 群⑧679858003
2、本站所有主题由该帖子作者发表,该帖子作者与运维网享有帖子相关版权
3、所有作品的著作权均归原作者享有,请您和我们一样尊重他人的著作权等合法权益。如果您对作品感到满意,请购买正版
4、禁止制作、复制、发布和传播具有反动、淫秽、色情、暴力、凶杀等内容的信息,一经发现立即删除。若您因此触犯法律,一切后果自负,我们对此不承担任何责任
5、所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其内容的准确性、可靠性、正当性、安全性、合法性等负责,亦不承担任何法律责任
6、所有作品仅供您个人学习、研究或欣赏,不得用于商业或者其他用途,否则,一切后果均由您自己承担,我们对此不承担任何法律责任
7、如涉及侵犯版权等问题,请您及时通知我们,我们将立即采取措施予以解决
8、联系人Email:admin@iyunv.com 网址:www.yunweiku.com

所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其承担任何法律责任,如涉及侵犯版权等问题,请您及时通知我们,我们将立即处理,联系人Email:kefu@iyunv.com,QQ:1061981298 本贴地址:https://www.yunweiku.com/thread-361809-1-1.html 上篇帖子: PHP基础知识之单引号和双引号的区别 下篇帖子: [转]优化PHP代码的40条建议
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

扫码加入运维网微信交流群X

扫码加入运维网微信交流群

扫描二维码加入运维网微信交流群,最新一手资源尽在官方微信交流群!快快加入我们吧...

扫描微信二维码查看详情

客服E-mail:kefu@iyunv.com 客服QQ:1061981298


QQ群⑦:运维网交流群⑦ QQ群⑧:运维网交流群⑧ k8s群:运维网kubernetes交流群


提醒:禁止发布任何违反国家法律、法规的言论与图片等内容;本站内容均来自个人观点与网络等信息,非本站认同之观点.


本站大部分资源是网友从网上搜集分享而来,其版权均归原作者及其网站所有,我们尊重他人的合法权益,如有内容侵犯您的合法权益,请及时与我们联系进行核实删除!



合作伙伴: 青云cloud

快速回复 返回顶部 返回列表