Smarty安装配置方法

yipeiwu_com6年前PHP基础知识

下载最新的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权限755

在templates目录下新建test.html:

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

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

相关文章

php循环输出数据库内容的代码

php do while方法     一般需要先$row=mysql_fetch_array($result)然后 do{ something...

用PHP中的 == 运算符进行字符串比较

最近在Greg Beaver's的blog上发表的一篇新文章 comparing strings in PHP with the == operator 中提及了PHP的 == 运...

ffmpeg处理pcm转mp3的参数设置详解

MP3截取ffmpeg -y -i test.mp3 -ss 00:00:00 -t 00:00:03 -acodec&...

PHP变量作用域(全局变量&局部变量)&global&static关键字用法实例分析

本文实例讲述了PHP变量作用域(全局变量&局部变量)&global&static关键字用法。分享给大家供大家参考,具体如下:我们知道,变量呢,其实就相当于我们用来储...

关于php缓存技术的基础讲解

缓存是指临时文件交换区,电脑把最常用的文件从存储器里提出来临时放在缓存里,就像把工具和材料搬上工作台一样,这样会比用时现去仓库取更方便。因为缓存往往使用的是RAM(断电即掉的非永久储存),...