Method for concatenating strings in the smarty Template
This article describes how to concatenate strings in the smarty template. For more information, see
Variables uploaded to the Smarty template on the PHP page (here, two variables are created on the Smarty)
The Code is as follows:
{Assign var = "name" value = 'Richard. Lil '}
{Assign var = "age" value = '27 '}
1. output in a certain position of the Smarty template (Richard. Lee --- 27)
Splicing method: {$ name | cat: "---" | cat: $ age}
Explanation: concatenates variables $ name, "---", and $ age into a string.
2. If you want to output (Name: Richard. Lee, age: 27) somewhere in the Smarty template, the splicing method is as follows:
Copy the Code as follows:
{"Name:" | cat: $ name | cat: ", age:" | cat: $ age}
{"Name:" | cat: $ name | cat: "," | cat: "age:" | cat: $ age}
Explanation: The two splicing methods have the same effect.
Note: The method found on the Internet is not very understandable | cat:, but after two simple examples, it is concluded that | cat: can be considered as a symbolic link string, it is equivalent to the point (.) in the PHP file (.).