Only output variables do not meet the needs of the template output, the built-in template engine support for template variables to use the regulator and formatting functions, in fact, is to provide function support, and support the use of multiple functions. The functions used for template labels can be PHP built-in functions or user-defined functions, unlike smarty, functions for templates do not require a special definition.
The function call format for the template variable is:
xml/html Code
- {$varnamefunction 1function2=arg1,arg2,###}
Description
{and $ symbol cannot have spaces, then the space of the argument is not a problem
# # #表示模板变量本身的参数位置
Supports multiple functions that support spaces between functions
Supports function masking, which allows you to configure a list of prohibited functions in a configuration file
Support variable caching function, repeated variable string not multiple resolution
Use examples:
xml/html Code
- {$WEBTITLEMD 5strtouppersubstr=0,3}
The compiled PHP code is:
PHP code
- Echo(SUBSTR (Strtoupper (MD5 ($webTitle)), 0, 3));?>
Note the relationship between the definition of a function and the order in which it is used, usually the first parameter of the function is the result of the previous variable or the previous function, and if your variable is not the first argument of the function, you need to use the anchor symbol, for example:
xml/html Code
- {$create _timedate=y-m-d,###}
The compiled PHP is:
PHP code
- Echo(Date (y-m-d, $create _time));?>
There is no limit to the use of functions, but you can allow the configuration tmpl_deny_func_list definition to disable the list of functions, and the Exit and ECHO functions are disabled by default to prevent damage to the template output, and we can add additional definitions, such as:
Tmpl_deny_func_list=>echo,exit,halt
Use a half-width comma to separate multiple functions.
It also provides a quick way to call a function directly in a template file without having to pass a template variable, including two ways:
1. Execute method and output return value:
Format: {: function (...)}
For example, output the return value of the U method:
xml/html Code
- {: U (' User/insert ')}
The compiled PHP code is
PHP code
- echo U (' User/insert ');? >
2, execution method but not output:
Format: {~function (...)}
For example, call the Say_hello function:
xml/html Code
- {~say_hello (' thinkphp ')}
The compiled PHP code is:
PHP code
- Say_hello (' thinkphp ');? >