Ways to use PHP functions in Smarty Templates

Source: Internet
Author: User

  1. 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
  2. Sample1
  3. The code is as follows:
  4. <{$colname| Trim}>
  5. What if I use a function like Iconv that has three parameters? If written as :
  6. Sample 2
  7. The code is as follows:
  8. <{$colname| Iconv: 'utf-8 ':' GBK '}>
  9. An error message is displayed when you execute it .  
  10. 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;
  11. That assumes that you want to use a function like Iconv with three parameters, write:
  12. Sample 3
  13. The code is as follows:
  14. <{' utf-8 '| Iconv:' GBK ':$colname}>
  15. Also
  16. 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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.