Php-smarty-2 (+), phpsmarty-219_php tutorial

Source: Internet
Author: User

Php-smarty-2 (+), phpsmarty-219


1. Delimiter

L Left_delimiter

L Right_delimiter

Smarty Default delimiter is: "{", "}"

If you need to change, you can set the above two properties

Template code:

Program code:

1. Template variable Assignment

Assign method two parameters

1) Template variable name

2) value

First, path settings

1. Several common paths in Smarty

1) Template path Template_dir

2) Compile Path Compile_dir

3) configuration file path Config_dir

4) cache file path Cache_dir

The above four paths are four properties under the Smarty class

2, in Smarty2.6, these properties can be set outside the class

Class smarty{

Var $template _dir;

Var $compile _dir;

Var $config _dir;

Var $cache _dir;

}

3. In Smarty3.0, this attribute is defined as:

protected $template _dir

protected $compile _dir

This is defined as a protected member, that is, we can inherit the Smarty class, and then we can have the few protected members.

Here, we find that these protected members can be set directly.

When assigning a value to a member that does not exist or is not accessible, the set is automatically executed

Automatically executes a get when a member that does not exist or is not accessible is evaluated

When a value or assignment is taken, the first check is whether the $allowed array in the method defines the element, and if it is defined, calls the Smarty method corresponding to the array element directly

Through the above code, you can be informed that in smarty3.0, there are eight methods specifically for these four attributes value and assignment

L Settemplatedir ()

L Setcompiledir ()

L Setconfigdir ()

L Setcachedir ()

L Gettemplatedir ()

L Getcompiledir ()

L Getconfigdir ()

L Getcachedir ()

We recommend that you use the above method for path setting

In the construction method of smarty, the default values are set for the above four properties.

Output Smarty Default path through the above program

http://www.bkjia.com/PHPjc/993274.html www.bkjia.com true http://www.bkjia.com/PHPjc/993274.html techarticle php-smarty-2, phpsmarty-219 1, delimiter l left_delimiter L right_delimiter Smarty The default delimiter is: {,} If you need to change, you can set the above two property template generation ... /c5>

  • 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.