Home > Backend Development > PHP Tutorial > Variable modifiers and function descriptions in five smarty

Variable modifiers and function descriptions in five smarty

不言
Release: 2023-03-28 16:36:01
Original
1329 people have browsed it

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 .

strip_tags

For example: {$articleTitle|strip_tags}, remove all html tags in the string;

date_format

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!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template