Php-Smarty-7 (24), phpsmarty-724_PHP tutorial

Source: Internet
Author: User
Php-Smarty-7 (24), phpsmarty-724. Php-Smarty-7 (24), phpsmarty-724 3. method lassign: assign variables to the template lassignByRef: assign variables to the template (pass by reference) The difference between Display and fetch: 4. filter the php-Smarty-7 (24 ), phpsmarty-724

III. Methods

L assign: assign variables to the template

L assignByRef: assign variables to the template (pass by reference)

Difference between Display and fetch:

IV. filter

A filter is used to filter data.

1. filter types:

1) prefilter Prefilters

2) Postfilters

3) Output filter Output Filters

Based on the trigger time, the above three filters are divided

2. workflow

Tpl source file => Prefilter => compile tpl file => Postfilter => save to disk => run the compiled PHP file => Output Filters (=> if there is a smarty cache, output Filters content will be cached) => result Output.

3. Register a filter

In Smarty, the filter must be registered before use

In 2.6, register the filter

L Prefilters

$ Smarty-> register_prefilter ("func ");

L Postfilters

$ Smarty-> register_postfilter ("func ");

L Output Filters

$ Smarty-> register_outputfilter ("func ");

Register different filters to call different methods.

3.0, register the filter

$ Smarty-> registerFilter ($ type, $ callback );

$ Type: filter type

Value range:

Pre: Pre-filter

Post: Post filter

Output: Output filter

$ Callback: filter function

4. Code:

The pre-filter and post-filter will be executed during the first compilation, or the template will be executed again after the template changes.

The output filter is executed every time.

Http://www.bkjia.com/PHPjc/995278.htmlwww.bkjia.comtruehttp://www.bkjia.com/PHPjc/995278.htmlTechArticlephp-Smarty-7 (24), phpsmarty-724 3. method lassign: assign variables to the template lassignByRef: assign variables to the template (pass by reference) The difference between Display and fetch: 4. filter...

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.