Home >Backend Development >PHP Tutorial >How to use custom functions in Thinkphp templates_PHP tutorial
Note: Custom functions should be placed in the project application directory/common/common.php. Here's the key.
Function calling format of template variables: {$varname|function1|function2=arg1, arg2, ### }
Note: There cannot be between
{ and the $ symbol If there are spaces, there will be no problem with spaces in subsequent parameters;
### indicates the parameter position of the template variable itself;
supports multiple functions, and spaces are supported between functions;
Supports function shielding function, and a list of prohibited functions can be configured in the configuration file;
Supports variable caching function, and repeated variable strings will not be parsed multiple times.
Usage example:
{$webTitle|md5|strtoupper|substr=0, 3}
{$number|number_format=2}
{ $varname|function1|function2=arg1, arg2, ### }
Example: