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()
And in the template
|
See also unregister_function() and the plugin functions section.
http://smarty.php.net/manual/en/api.register.function.php
当前版本 2.6.18, http://smarty.php.net/do_download.php?download_file=Smarty-2.6.18.tar.gz
全部列表, http://smarty.php.net/download.php
借助cycle实现循环输出值, http://smarty.php.net/manual/en/language.function.cycle.php
Smarty的cat函数, http://smarty.php.net/manual/en/language.modifier.cat.php
Smarty的upper函数, http://smarty.php.net/manual/en/language.modifier.upper.php
cat将值连接到给定变量之后, http://smarty.php.net/manual/en/language.modifier.cat.php
upper将字符串转换成大写字母, http://smarty.php.net/manual/en/language.modifier.upper.php
escape转义修饰符, http://smarty.php.net/manual/en/language.modifier.escape.php
{config_load}用于从一个配置文件加载配置变量到模板中, http://www.smarty.net/manual/en/language.builtin.functions.php
{strip}在显示之前删除每行前后多余的空格和回车字符, http://smarty.php.net/manual/en/language.function.strip.php
{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
assign_by_ref()按引用赋值, http://smarty.php.net/manual/en/api.assign.by.ref.php