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

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

PHP中for循环语句的几种变型

for语句可以说是PHP(同时也是多种语言)的循环控制部份最基本的一个语句了,for语句的执行规律和基础用法在这里就不多说,可以参见PHP手册for语句部分。PHP手册中对它的语法定义如下...

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

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

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

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

PHP使用JPGRAPH制作圆柱图的方法详解

PHP使用JPGRAPH制作圆柱图的方法详解

本文实例讲述了PHP使用JPGRAPH制作圆柱图的方法。分享给大家供大家参考,具体如下:制作圆柱图像的要点首先,要使用jpgraph库,我们先要去官网进行下载,网址:https://jpg...