zoukankan      html  css  js  c++  java
  • Smarty 的安装

    1、下载Smarty包
    可以从官方站点下载:http://smarty.php.net/

    2、解压缩Smarty包
    解压后的文件夹重命名为Smarty,放置在C:Apache2include下

    3、修改配置文件php.ini的include_path选项,把smarty的库文件路径加上
    include_path = “C:Apache2includeSmartylibs”

    4、在你的网站目录下创建一个文件夹smarty:
    然后再在这个Smarty目录下创建4个文件夹,templates(存放模版)、configs(存放一些配置信息)、template-c(存放编译文件)和cache(存放缓存)。

    phperz~com

    5、注意:

    php.ini中一共有两处include_path,一处是Unix下使用的,一处是windows下使用的,要修改windows下使用的

    如果不设置include_path,可以直接把Smarty.class.php拷到网站目录

    phperz.com

    6. Linux下,将 templates_c 的权限变更为 777 .

    php程序员之家

    phperz.com

    <?php
    //载入Smarty库,如果在php.ini设置了include_path为D:AppservwwwMysmartylibs,那么可以直接用include("Smarty.class.php");
    //另外不设置include_path,可以直接把Smarty.class.php拷到网站目录,就不用加绝对路径了。
    require('../../Smarty/libs/Smarty.class.php');

    phperz.com

    $smarty = new Smarty;
    //新建的文件夹//
    //下面的(你的网站目录)用绝对路径,可以用相对路径(./templates)
    $smarty->template_dir='../templates'; //这个目录用来存放模版
    $smarty->config_dir='../configs';//这个目录用来存放一些配置信息
    $smarty->cache_dir='../cache';//这个目录用来存放缓存
    $smarty->compile_dir='.. emplates_c';//这个目录用来存放编译文件
    //上面四行为使用Smarty前的必要参数配置 phperz.com

    $smarty->left_delimiter = "{";
    $smarty->right_delimiter = "}";
    //////////////////////////////////////////////////////////////////////////////////////////////////////////
    $smarty->assign('name','明天');
    $smarty->assign("name_1", "哈哈哈");
    $smarty->display('index.html');

    php程序员之家

    ?>

  • 相关阅读:
    数据表格优化
    vue数组和对象的监听变化
    python flask框架搭建以及大佬代码参考
    简单爬虫
    srs的基本配置
    记录飞天程序库调用
    面试题 递归算法1+2+....+100求和
    下载列表组件
    Prometheus之系统安装,启动
    nginx之日志
  • 原文地址:https://www.cnblogs.com/Catherine2011/p/6543098.html
Copyright © 2011-2022 走看看