Smarty安装配置方法

yipeiwu_com4年前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中的字符串操作功能是比较多的,重要的有以下这些:    (1)echo,print,printf,sprintf &...

php 使用 __call实现重载功能示例

本文实例讲述了php 使用 __call实现重载功能。分享给大家供大家参考,具体如下:<?php /**  * Created by Ph...

PHP超级全局变量【$GLOBALS,$_SERVER,$_REQUEST等】用法实例分析

本文实例讲述了PHP超级全局变量用法。分享给大家供大家参考,具体如下:$GLOBALS$_SERVER$_REQUEST$_POST$_GET$_FILES$_ENV$_COOKIE$_S...

PHP编程中字符串处理的5个技巧小结

字符串 注意单引号和双引号的区别 注意转义字符\的使用\\,\",\$ 注意使用8进制或16进制字符表示 \xf6 echo "H\xf6me&qu...

PHP 常见郁闷问题答解

在register_global默认为off 若想取得从另一页面提交的变量: 方法一:在PHP.ini中找到register_global,并把它设置为on. 方法二:在接收网页最...