Getting started with configuring and using the Smarty environment

Source: Internet
Author: User
This article mainly introduces how to configure and use the Smarty environment, and analyzes in detail the meanings of setting up and configuring parameters in the Smarty environment, which is very easy to understand, for more information about how to configure and use the Smarty environment, see the following example. We will share this with you for your reference. The details are as follows:

Download Smarty (here we use Smarty-2.6.26 as an example ). Decompress the downloaded file (the directory structure is quite complex ). Next we will show you how to install an instance.

(1) create a new directory named learn/under the root directory, and create a directory named smarty/In learn /. Copy the libs/from the extracted directory to smarty/, create the templates directory in smarty/, and create cache/, templates/, templates_c/, and config/in templates /.

(2) create a new template file: index. tpl. Place the file in the learn/smarty/templates Directory. the code is as follows:

 
  Smarty{#$hello#}
 

Create index. php and put this file under learn:

<? Phprequire 'smarty/libs/smarty. class. php '; $ smarty = new Smarty; // set the path of each directory. here is the installation focus $ smarty-> template_dir = "smarty/templates "; $ smarty-> compile_dir = "smarty/templates/templates_c"; $ smarty-> config_dir = "smarty/templates/config "; $ smarty-> cache_dir = "smarty/templates/cache"; // The smarty template provides the high-speed cache function. if it is true, caching is enabled, however, the webpage may not be updated immediately. you can also use other methods to solve the problem $ smarty-> caching = false; $ smarty-> left_delimiter = "{#"; // re-define the boundary. because the default boundary "{}" character is used to embed the js script file into the html page to compile the code segment, the custom boundary can also be <{}> ,{/

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.