Smarty安装配置方法

下载最新的Smarty:http://smarty.php.net/

解压后将目录中的libs目录重命名为smarty,复制到你的网站目录,同时在网站根目录下建立templates和templates_c两个目录 建立test.php,内容如下:

<?php
include_once('./Smarty/Smarty.class.php');
$smarty = new Smarty();
$smarty -> template_dir = "./templates"; //模板存放目录
$smarty -> compile_dir = "./templates_c"; //编译目录
$smarty -> left_delimiter = "{{"; //左定界符
$smarty -> right_delimiter = "}}"; //右定界符
$smarty -> assign('test','OK');
$smarty -> display('test.html');
?>

给templates_c权限

在templates目录下新建test.html:

<html> <head> </head> <body> {{$test}} </body> </html>

打开test.php,如果看到OK就说明你的smarty安装成功了!

详细出处参考:http://www.jb51.net/article/14132.htm

原文地址:https://www.cnblogs.com/loveAnimal/p/3296231.html