Home  >  Article  >  Backend Development  >  Installation configuration of smarty template

Installation configuration of smarty template

WBOY
WBOYOriginal
2016-08-08 09:22:24970browse

Step 1: Download the Smarty template source code package
Click "Smarty Download" on Baidu to download the latest version of Smarty template
Part 2: Unzip, unzip the downloaded Smarty package
Right-click ->Extract to the current file Folder...you know ^_^
Part 3: Installation and Configuration
1. Enter the decompressed folder, copy the libs folder in the folder to your own working path, and the installation is complete! Is this the installation? Yes, no doubt, this is the installation, haha, it’s simple enough! ^_^
2. Rename the libs folder you just copied to your favorite folder name. I will use the domain name phpname of this site to name it
3. Create the following in the same directory as the phpname folder Several folders (you can name them yourself, but they must correspond to the next step of configuration): templates (the directory used to store templates), templates_c (used to store compiled files), cache (used to store Cached directory), config (directory used to store configuration)
4. Create a new smarty.php configuration file in the same directory as phpname (you can also name it yourself, what name should you choose here when you want to use Smarty. What name is introduced in the php file), the code is as follows:
& lt;? PHP
Include ('./phpname/smarty.class.php'); // Introduce the file class
$ Smarty = New Smarty; // instantiated
$smarty->template_dir="templates"; //Specify the template storage directory
        $smarty->compile_dir="templates_c"; //Specify the compiled file storage directory
                  $smarty->c //                         $smarty->c //Specify the directory to store the configuration files ... ;{"; //Specify the left label
              $smarty->right_delimiter="}>"; //                                                                                                                            It’s also very simple! ^_^
Part 4: Test
Now that the installation and configuration are done, let’s test if it works
1. Create a new index.html test file in the templates folder. The test code is as follows:


                                                                                          ​ ? & Lt;? PHP
Include ("Smarty.php"); // Introduce configuration files
$ name = "ok"; // Define variables
$ SMARTY- & GT; assign ('name', $ name); // Replace the <{$name}>
in the template with the value of the defined variable $name ("OK") $smarty->display("index.html"); //Display the index in the template folder .html
?>
3. Start your server and visit http://localhost/???/phpname/index.php. If the page displays "OK", it means that the Smarty installation and configuration is successful! If "OK" is not displayed, recheck the above steps. I have tested it locally and there is no problem at all! Good luck!

Reprinted from http://www.phpname.com/phpname_182013020733.html

The above introduces the installation and configuration of the smarty template, including the relevant aspects. I hope it will be helpful to friends who are interested in PHP tutorials.


Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Previous article:centos installation pearNext article:centos installation pear