How to install and use the smarty template engine in Linux

Source: Internet
Author: User
Tags smarty template
The initialization method for installing and using the smarty template engine in Linux-Linux Enterprise Application-Linux server application information. For more information, see the following. Install Smarty:
1. Download and decompress the package
2. Copy the libs folder to the/var/www/html directory.
3. Create a New Mysmarty folder in the/var/www/html directory.
4. Create Four folders named cache, templates, templates_c, and configs in the Mysmarty folder.
5. Set the templates and templates_c permissions to 777.

Test Smarty
1. Create test. php In the Mysmarty folder. The content is as follows:
CODE:  
Include ("/var/www/html/libs/Smarty. class. php"); // contains the smarty class file
$ Smarty = new Smarty (); // create a smarty Instance Object $ smarty
$ Smarty-> template_dir = '/var/www/html/Mysmarty/templates ';
$ Smarty-> compile_dir = '/var/www/html/Mysmarty/templates_c ';
$ Smarty-> config_dir = '/var/www/html/Mysmarty/configs ';
$ Smarty-> cache_dir = '/var/www/html/Mysmarty/cache ';
$ Smarty-> caching = false;

$ Smarty-> left_delimiter = "<{";
$ Smarty-> right_delimiter = "}> ";
  

$ Smarty-> assign ("title", "test"); // replace template Variables
$ Smarty-> assign ("content", "bbbbbbbbbxxxxxxxbbbbbbbbbbbbbb ");

// Compile and display the index. tpl Template under./templates
$ Smarty-> display ("test. tpl ");//
?>
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.