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

相关文章

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

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

php7性能提升的原因详解

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

PHP实现文件分片上传的实例代码

PHP实现文件分片上传的实例代码

PHP用超级全局变量数组$_FILES来记录文件上传相关信息的。1.file_uploads=on/off是否允许通过http方式上传文件2.max_execution_time=30允许脚本最大执行...

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

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

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

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