Home > Backend Development > PHP Tutorial > SMARTY Learning Notes_PHP Tutorial

SMARTY Learning Notes_PHP Tutorial

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
Release: 2016-07-21 15:58:10
Original
884 people have browsed it

You cannot learn PHP without mentioning SMARTY. As a famous template program, SMARTY naturally has its advantages. Below is a summary of my own learning experience!
=================================
first at Smarty.php.net Download the latest smarty
Put the libs folder in your WEB directory. I placed it under smarty. The directory is as follows: e:/smarty/libs
Create the following folder in the smarty directory:
templates (put your template files here, that is, tpl files)
configs
templates_c (automatically convert the compiled files into PHP and put them here)
cache
Then create index in the wwwroot directory .php:
include "smarty/libs/Smarty.class.php";
define('__SITE_ROOT', 'e:/smarty'); // No slash at the end
$tpl = new Smarty();
$tpl->template_dir = __SITE_ROOT . "/templates/";
$tpl->compile_dir = __SITE_ROOT . "/templates_c/";
$ tpl ->config_dir = __SITE_ROOT . "/configs/";
$tpl->cache_dir = __SITE_ROOT . "/cache/";
//$tpl->left_delimiter = '<{'; Can be changed as needed.
//$tpl->right_delimiter = '}>';
$tpl->assign('name','world!');
$tpl->display('index .tpl')
?>

Create index.tpl in the template directory:


New Document







hello,{$name}~.





Then the local index.php displays hello, world!~.

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/317624.htmlTechArticleYou cannot learn PHP without mentioning SMARTY. As a famous template program, SMARTY naturally has its advantages. Below is a summary of my own learning experience! ==============...
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
Latest Issues
smarty turns on caching garbled characters
From 1970-01-01 08:00:00
0
0
0
Why does tp use smarty template? ?
From 1970-01-01 08:00:00
0
0
0
How do you use smarty to integrate laravel5?
From 1970-01-01 08:00:00
0
0
0
Two ways to install smarty
From 1970-01-01 08:00:00
0
0
0
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template