- In the smarty template, if you want to use PHP functions in the displayed data , if it is a function with only one parameter, for example, a blank trim will be written
- Sample1
- The code is as follows:
- <{$colname| Trim}>
- What if I use a function like Iconv that has three parameters? If written as :
- Sample 2
- The code is as follows:
- <{$colname| Iconv: 'utf-8 ':' GBK '}>
- An error message is displayed when you execute it .
- Therefore, the study will find that starting in the smarty template page of the application function usage, in smaple 1 ,trim front $Row - ColName is actually the first parameter of trim, in the middle with | This symbol is threaded;
- That assumes that you want to use a function like Iconv with three parameters, write:
- Sample 3
- The code is as follows:
- <{' utf-8 '| Iconv:' GBK ':$colname}>
- Also
- Function First Argument | function: Second argument: third argument. in Sample 3 , the value of ColName is converted from UTF-8 format to GBK.
Ways to use PHP functions in Smarty Templates