php register_function smarty,PHP - Smarty模板引擎 - Manual手册 - 翻译中 - 第13章 Smarty类方法 - register_function(...

PHP - Smarty模板引擎 - Manual手册 - 翻译中 - 第13章 Smarty类方法 - register_function()动态注册模板函数插件

register_function()

register_function() -- dynamically register template function plugins

register_function() -- 动态注册模板函数插件

Description

描述 void

register_function ( string name, mixed impl [, bool cacheable [, mixed cache_attrs]])

Pass in the template function name, followed by the PHP function name that implements it.

The php-function callback function can be either:

A string containing the function name

An array of the form array(&$object, $method) with &$object being a reference to an object and $method being a string containing the method-name

An array of the form array($class, $method) with $class being the class name and $method being a method of the class.

cacheable and cache_attrs can be omitted in most cases. See controlling cacheability of plugins output on how to use them properly.

Example 13-1. register_function()

<?php $smarty->register_function('date_now','print_current_date');functionprint_current_date($params, &$smarty){  if(empty($params['format'])) {$format="%b %e, %Y";  } else {$format=$params['format'];  }  returnstrftime($format,time());}?>

And in the template

{date_now}{* or to format differently *}{date_now format="%Y/%m/%d"}

[PHP - Smarty模板引擎 - Manual手册 - 翻译中 - 第13章 Smarty类方法 - register_function()动态注册模板函数插件 - 用途] 实现自定义标记

[PHP - Smarty模板引擎 - Manual手册 - 翻译中 - 第13章 Smarty类方法 - register_function()动态注册模板函数插件 - 文档]

[PHP - Smarty模板引擎 - 官方网站]

http://smarty.php.net/

[PHP - Smarty模板引擎 - 下载地址]

[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手册]

[PHP - Smarty模板引擎 - Manual手册 - Chapter 3. Basic Syntax第3章 基础语法]

Comments注释, http://smarty.php.net/manual/en/language.basic.syntax.php#language.syntax.comments

Math数学运算, http://smarty.php.net/manual/en/language.math.php

[PHP - Smarty模板引擎 - Manual手册 - Chapter 5. Variable Modifiers第5章 变量修饰符]

[PHP - Smarty模板引擎 - Manual手册 - Chapter 7. Built-in Functions第7章 内建函数]

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

[PHP - Smarty模板引擎 - Manual手册 - Chapter 8. Custom Functions第8章 自定义函数]

[PHP - Smarty模板引擎 - Manual手册 - 第13章 Smarty类方法]

register_function()动态注册模板函数插件, http://smarty.php.net/manual/en/api.register.function.php

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值