The string concatenation method in the smarty template. Copy the code from the PHP page to the variables uploaded to the Smarty template (here, two variables are created on the Smarty instead) as follows: {assignvarnamevalueRichard. lee} {assignvaragev PHP page to the variables uploaded to the Smarty template (used 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:
The code is 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 (.).
Usage (here, two variables are created on Smarty instead) code: {assign var = "name" value = 'Richard. lee '} {assign var = "age" v...