You can also do this:
Output results: 1 2 3 4 5 ... ... 100 In addition, let’s introduce how to use php functions in smarty. In the smarty template, if you use the php function, a function with only one parameter, such as removing blank trim, can be written like this: example 1:
So what should I write if I use a function with three parameters like iconv? If written: Example 2:
You will find an error message displayed as soon as you execute it. Starting from the application function usage on the smarty template page, taking Example 1 as an example, the $Row->colname in front of trim is actually the first parameter of trim, and is concatenated with the symbol | in the middle; If you want to use a function with three parameters like iconv, you should write: Example 3:
That is, the first parameter of the function | function: the second parameter: the second parameter three parameters. In Example 3, the value of colname will be converted from utf-8 format to gbk. |