Smarty安装配置方法

yipeiwu_com5年前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中的 == 运算符进行字符串比较

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

php 多继承的几种常见实现方法示例

本文实例讲述了php 多继承的几种常见实现方法。分享给大家供大家参考,具体如下:class Parent1 {   function m...

PHP高并发和大流量解决方案整理

一、高并发的概念在互联网时代,并发,高并发通常是指并发访问。也就是在某个时间点,有多少个访问同时到来。二、高并发架构相关概念1、QPS (每秒查询率) : 每秒钟请求或者查询的数量,在互联...

echo(),print(),print_r()之间的区别?

echo是PHP语句, print和print_r是函数,语句没有返回值,函数可以有返回值(即便没有用)   print只能打印出简单类型变量的值(如int,strin...

怎样使用PHP中的字符串函数

    PHP中的字符串操作功能是比较多的,重要的有以下这些:    (1)echo,print,printf,sprintf &...