Smarty-2 (19)

Source: Internet
Author: User
: This article mainly introduces Smarty-2 (19). If you are interested in the PHP Tutorial, refer to it. 1. delimiters

L left_delimiter

L right_delimiter

Smarty's default delimiter is: "{", "}"

If you need to change the attributes, you can set the above two attributes.

Template code:

Program code:

1. template variable assignment

Two parameters of the Assign method

1) template variable name

2) value

I. path settings

1. several common paths in Smarty

1) template path: template_dir

2) compilation path: compile_dir

3) configuration file path: config_dir

4) cache file path cache_dir

The preceding four paths are the four attributes of the smarty class.

2. in Smarty2.6, these attributes 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 follows:

Protected $ template_dir

Protected $ compile_dir

It is defined as a protected member, that is, we can inherit the smarty class and then have these protected members.

Here, we found that you can directly set these protected members.

If a value is assigned to a non-existent or inaccessible member, the set

When the value is set to a nonexistent or inaccessible member, get is automatically executed.

When values or values are assigned, first check whether the $ allowed array in the method defines the element. If yes, call the smarty method corresponding to the array element.

The code above shows that there are eight methods in smarty3.0 specifically for the values and assignments of these four attributes.

L setTemplateDir ()

L setCompileDir ()

L setConfigDir ()

L setCacheDir ()

L getTemplateDir ()

L getCompileDir ()

L getConfigDir ()

L getCacheDir ()

We recommend that you use the preceding method to set the path.

In the Smarty constructor, the default value is set for the preceding four attributes.

Use the above program to output the default path of smarty

The above introduces Smarty-2 (19), including some content, and hope to be helpful to friends who are interested in PHP tutorials.

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.