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安装成功了!
                       

相关文章

php7性能提升的原因详解

为什么PHP7的性能可以提高这么多?1. JIT 2. Zval的改变 3. 内部类型zend_string 4. PHP数组的变化(HashTable和Zend Array) 5. 函数...

设定php简写功能的方法

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

使用PHP的日期与时间函数技巧

PHP的日期时间函数date() 1,年-月-日 echo date('Y-m-j');  2007-02-6  echo da...

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

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

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

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