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简写功能的方法

本教学使用环境介绍伺服器端:Ubuntu 18.04 LTS资料库:Mariadb 10.1.34(Mysql)语言版本:php 7.3本机端:MacOS High Sierra启用 ph...

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

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

php 多个变量指向同一个引用($b = &$a)用法分析

本文实例讲述了php 多个变量指向同一个引用($b = &$a)用法。分享给大家供大家参考,具体如下:引用是什么? 引用就是多个变量指向同一个内存区域地址。如我们经常用的实例一个类...

如何判断php复选框是否被选中

复选框checkbox通常用于php表单提交。本文通过实例给大家介绍php如何判断复选框中的值是否被选中。需要它的朋友可以参考本文中的例子。本文章向大家介绍两个知识点:1.php表单提交如...

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

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