PHP and MySQL programming (version 3rd) -- 19.3 install Smarty

Source: Internet
Author: User
Tags php and mysql

19.3 install Smarty

Installing Smarty is very simple. First, download the latest stable version at http://smarty.php.net. Run the following command to install Smarty.

(1) decompress the package to a location outside the root directory of the Web document. Ideally, other PHP libraries imported to a specific application should also be placed in this location. For example, in UNIX, this location may be:

In Windows, this location may be:

(2) because the Smarty class library needs to be included in the application, make sure that this location is included in the plude_path configuration instruction of PHP. The class file is Smarty. class. php, which is located in the Smarty directory libs /. For example, the preceding command should be set in UNIX as follows:

In Windows, it should be set:

Of course, you may want to append this path to another path in include_path, because you may want to integrate various libraries into the application in the same way. Remember, after making changes to the PHP configuration file, you need to restart the Web server. In addition, you can use other methods to allow applications to reference the Smarty library. For example, you can simply provide the full absolute path of the class library. Another way is to set a predefined constant named SMARTY_DIR, pointing to the directory of the Smarty class library, and then the class library name starts with this constant. Therefore, even if a configuration makes it impossible to modify the php. ini file, you must be aware that this does not prevent you from using Smarty.

(3) create four directories for storing the Smarty template and configuration file.

Q templates. Place all website templates. The next section will learn more about the template structure.

Q configs. All the special Smarty configuration files used in a specific website. Section 19.6 describes the specific functions of these files.

Q templates_c. Place all templates compiled by Smarty.

Q cache. When the cache feature is enabled, all templates cached by Smarty are placed.

By default, Smarty considers these directories to be in the same directory as the scripts that instantiate the Smarty class, but it is recommended that these directories be placed outside the Web server document root. You can use $ template_dir, $ compile_dir, $ config_dir, and $ cache_dir of Smarty to modify the default behavior. Therefore, you can change its location:

 

After completing these three steps, you can use Smarty. To make you more interested in this templated engine, let's start with a simple example and then discuss more interesting and useful features.

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.