1、下载Smarty包可以从官方站点下载:http://smarty.php.net/
2、解压缩Smarty包解压后的文件夹重命名为Smarty,放置在C:\Apache2\include下
3、修改配置文件php.ini的include_path选项,把smarty的库文件路径加上include_path = “C:\Apache2\include\Smarty\libs”
4、在你的网站目录下创建一个文件夹smarty:然后再在这个Smarty目录下创建4个文件夹,templates(存放模版)、configs(存放一些配置信息)、template-c(存放编译文件)和cache(存放缓存)。
phperz~com
5、注意:
php.ini中一共有两处include_path,一处是Unix下使用的,一处是windows下使用的,要修改windows下使用的
如果不设置include_path,可以直接把Smarty.class.php拷到网站目录
phperz.com6. Linux下,将 templates_c 的权限变更为 777 .
php程序员之家
phperz.com
<?php//载入Smarty库,如果在php.ini设置了include_path为D:\Appserv\www\Mysmarty\libs,那么可以直接用include("Smarty.class.php");//另外不设置include_path,可以直接把Smarty.class.php拷到网站目录,就不用加绝对路径了。require('../../Smarty/libs/Smarty.class.php');
phperz.com
$smarty = new Smarty;//新建的文件夹////下面的(你的网站目录)用绝对路径,可以用相对路径(./templates)$smarty->template_dir='../templates'; //这个目录用来存放模版$smarty->config_dir='../configs';//这个目录用来存放一些配置信息$smarty->cache_dir='../cache';//这个目录用来存放缓存$smarty->compile_dir='..\templates_c';//这个目录用来存放编译文件//上面四行为使用Smarty前的必要参数配置 phperz.com
$smarty->left_delimiter = "{";$smarty->right_delimiter = "}";//$smarty->assign('name','明天');$smarty->assign("name_1", "哈哈哈");$smarty->display('index.html');
php程序员之家
?>
转载于:https://www.cnblogs.com/Catherine2011/p/6543098.html
相关资源:Smarty安装配置方法