Home > Backend Development > PHP Tutorial > A preliminary understanding of Samrty technology

A preliminary understanding of Samrty technology

WBOY
Release: 2016-08-08 09:28:22
Original
1172 people have browsed it
<span style="font-size:18px;">Smarty 技术的使用
<?php 
#smarty 测试
#引入smarty 
require_once "./smarty/Smarty.class.php";   #必须加载该类文件
#生成一个smarty对象
$smarty = new Smarty();
#设置smarty
$smarty->left_delimiter='{';	#左修饰符
$smarty->right_delimiter='}';	#右修饰符
$tpl=$smarty->template_dir ="./libs/view/template"; #模板文件
$smarty->cache_dir ="./libs/view/cache";			 #缓存文件
$smarty->compile_dir ="./libs/view/template_c";  #编译文件
$smarty->caching = true;  #开启缓存
$smarty->cache_lifetime = 100; #缓存生命周期

#使用模板方法
$smarty->assign('test','this is testSmarty!');   #进行赋值
$smarty->display("index.tpl");	#输出 (必须在指定的目录下存在该文件,文件中用{$test} 表示以上赋值的‘test’)</span>
Copy after login

The above has introduced a preliminary understanding of Samrty technology, including aspects of it. 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