Php-smarty-7 (24)

Source: Internet
Author: User
Third, the method

L Assign: assigning variables to templates

L ASSIGNBYREF: Assigning variables to templates (passed by reference)

L Append: Append template variable to an array

L appendbyref: Append template variable to an array (passed by reference)

L Clearallassign

Clear all assigned variables

L ClearCache

Clear Cache

L Configload Load configuration file

In Smarty, load the configuration file in two ways:

1) in the template {config_load file= ' ... '}

2) $smarty->configload in the program ($file [, $section])

L Clearconfig

Clear all configuration file variables

L Display

Read, replace, output

L Fetch

Read, replace, return

L Templateexists: Determine if template exists

Attempting to load a non-existent template will cause an error and should be judged before the display

The difference between assign and Assignbyref:

the difference between display and fetch:

Four, filter

Filters are used to filter data

1, the type of filter:

1) Pre-filter prefilters

2) Rear Filter postfilters

3) Output filter outputs Filters

According to the different trigger time, the above three kinds of filters are divided.

2. Work Flow

TPL source file =〉prefilter =〉 Compile tpl file = = Postfilter = Save to disk + compiled PHP file execution =〉output Filters (=〉 If there is smarty cache, Output The content of the filters is cached) and the output of the result.

3. Register Filter

In smarty, filters must be registered before they are used

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 invoke different methods.

3.0, Register Filter

$smarty->registerfilter ($type, $callback);

$type: Filter Type

Range of values:

Pre: Preset Filter

Post: Post filter

Output: Export filter

$callback: Filter function

4. Code:

Pre-and post-filters are executed the first time the compilation occurs, or the template is changed and executed again

The output filter executes every time

The above describes the Php-smarty-7 (24), including the aspects of the content, I hope that the PHP tutorial interested in a friend helpful.

  • Related Article

    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.