How to use PHP functions in the smarty template _ PHP Tutorial

Source: Internet
Author: User
Use PHP functions in the smarty template. Sample 1 copies the code as follows: {$ colname | trim}. how can I write a function with three parameters like iconv? If the code is: sample2, copy the code as follows: {$ co sample1

The code is as follows:


<{$ Colname | trim}>


How can I write a function with three parameters like iconv? If it is written:
Sample 2

The code is as follows:


<{$ Colname | iconv: 'utf-8': 'gbk'}>


An error message is displayed upon execution.
Therefore, we will find that, starting from the usage of the functions applied on the smarty template page, in smaple 1, $ Row-> colname in front of trim is actually the first parameter of trim, use | in the middle to concatenate;
If you want to use a function with three parameters like iconv, you must write it as follows:
Sample 3

The code is as follows:


<{'Utf-8' | iconv: 'gbk': $ colname}>


That is
The first parameter of the function | function: the second parameter: the third parameter. In sample 3, the colname value is converted from UTF-8 to gbk.

The http://www.bkjia.com/PHPjc/323258.htmlwww.bkjia.comtruehttp://www.bkjia.com/PHPjc/323258.htmlTechArticlesample1 code is as follows: {$ colname | trim}, if you use a function with three parameters like iconv, how do you write it? Sample 2 code: {$ co...

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.