钢琴第一节课试课游戏:安装smarty

来源:百度文库 编辑:九乡新闻网 时间:2024/04/30 01:44:14
安装Smarty过程:
1 下载Smarty-3.0.8.tar.gz并且解压
2 将libs文件夹复制到目录/var/www/html(此目录可以更改为自己放置php文件的目录)
3 在/var/www/html目录下新建Mysmarty文件夹
4 在Mysmarty文件夹下新建4个文件夹cache,templates,templates_c,configs
5 将templates,templates_c权限改为7776.修改/usr/local/apache2/conf/httpd.conf中的l两行为:DocumentRoot "/var/www/html/Mysmarty" 测试Smarty1 在Mysmarty文件夹下面建立test.php,内容如下: 
include("/var/www/html/libs/Smarty.class.php"); //包含smarty类文件
$smarty = new Smarty(); //建立smarty实例对象$smarty
$smarty->template_dir = '/var/www/html/Mysmarty/templates';
$smarty->compile_dir = '/var/www/html/Mysmarty/templates_c';
$smarty->config_dir = '/var/www/html/Mysmarty/configs';
$smarty->cache_dir = '/var/www/html/Mysmarty/cache';
$smarty->caching = false;$smarty->left_delimiter = "<{";
$smarty->right_delimiter = "}>";
  $smarty->assign("title", "test"); //进行模板变量替换
$smarty->assign("content","BBBBBBBXXXXXXXXXBBBBBBBBBBBB");//编译并显示位于./templates下的index.tpl模板
$smarty->display("test.tpl"); //
?>
2 templates下建立test.tpl  
  
  
  <{$title}>
  
  
  <{$content}>
  
  
 本篇文章来源于 Linux公社网站(www.linuxidc.com)  原文链接:http://www.linuxidc.com/Linux/2008-10/16262.htm