Home >Backend Development >PHP Tutorial >Variable modifiers and function descriptions in five smarty
This article mainly introduces the variable regulators and function descriptions in the five smarty. It has a certain reference value. Now I share it with you. Friends in need can refer to it
default
For example: {$arr|default:'xxxx'}, default Variable regulator, when the variable is empty, the given default value is displayed; set a default value for the empty variable, when the variable is When empty or unallocated, the given default value is used instead.
truncate
For example: {$articleTitle|truncate:10}, cut the string to the specified length; intercept characters of a certain length starting from the string, default It's 80.
count_characters
For example: {$articleTitle|count_characters}, get the string length; calculate the number of characters in the variable value, the parameter value Brown determines whether to count the number of spaces, the default is not to count spaces .
For example: {$articleTitle|strip_tags}, remove all html tags in the string;
For example: {$smarty.now|date_format('')}, format timestamp; date formatting, the first parameter controls the date format, if the data passed to date_format Is empty, the second parameter will be used as the default time.
Related recommendations:
Solution to the failure of Smarty variable regulator, smarty variable regulator_PHP tutorial
The above is the detailed content of Variable modifiers and function descriptions in five smarty. For more information, please follow other related articles on the PHP Chinese website!