Home > Backend Development > PHP Tutorial > smarty template basic construction of smarty template

smarty template basic construction of smarty template

WBOY
Release: 2016-07-28 08:25:29
Original
1132 people have browsed it

1. Download the smarty template, it’s official

2. Unzip it and you will get a directory like this

 smarty模板的基础搭建

Except the libs folder, you can delete the rest (I don’t know what the use is).

3. Create templates, templates_c, cache, and config folders in the current directory. Other names are also acceptable, but the configuration file needs to be modified.

4. Create a folder in the root directory with whatever name you want. Create php file, paste the following code into it.

require_once("libs/smarty.class.php");
$smarty=new smarty();
$smarty->template_dir="templates";//Specify the path to the template file
$smarty->compile_dir ="templates_c";//Specify the compiled file path
$smarty->cache_dir="cache";//Specify the cache file path
$smarty->c c />

<{$name}>



6. When running the php file, he will definitely report an error like this

 smarty模板的基础搭建

Due to the problem of the configuration file path, it would be better to change it to this. Because the file that is not being executed is not in the root directory, this error will be reported.

 smarty模板的基础搭建

7. The most basic smarty framework has been built. The main problem is that errors will be made due to path problems. If there is an error like the following

 smarty模板的基础搭建

, this means that there is no problem with the imported file. However, the configuration is wrong, like below In this way, novices can easily get confused.

 smarty模板的基础搭建

The above introduces the basic construction of smarty template smarty template, including the content of smarty template. I hope it will be helpful to friends who are interested in PHP tutorials.

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template