• Smarty 官网:

  1. http://www.smarty.net/
  • Smarty 下载:

  1. https://github.com/smarty-php/smarty/releases/tag/v3.1.30
  2. // 下载 tar.gz 放到你的网站服务器中,和 jQuery和 Bootstrap 配合使用。
  • Smarty 使用例程

  1. // 假设 Smarty 框架已经解压在 /var/www 目录下,此目录是apache2 的家目录
  2. // 现在,先写一个main.php
  3. // main.php
  4. <?php
  5. include "smarty-3.1.30/libs/Smarty.class.php";
  6. define ("__SITE_ROOT", "/var/www");
  7. require_once('includes/include.php');
  8. require_once('includes/functions.php');
  9. $tpl = new Smarty();
  10. $tpl->template_dir = __SITE_ROOT . "/templates/"; // 指定模板目录
  11. $tpl->compile_dir = __SITE_ROOT . "/templates_c/"; // 指定临时生成的网站目录
  12. $tpl->config_dir = __SITE_ROOT . "/configs/"; // 指定配置文件目录
  13. $tpl->cache_dir = __SITE_ROOT . "/cache/"; // 指定缓存目录,这个目录里面放着最终显示的网站php 文件
  14. $tpl->left_delimiter = '<{';
  15. $tpl->right_delimiter = '}>';
  16. ?>
  1. // 创建一些文件夹
  2. mkdir templates templates_c configs cache
  1. // 编写模板
  2. // vim templates/test.htm
  3. <html>
  4. <head>
  5. <meta http-equiv="Content-Type" content="text/html; charset=big5">
  6. <title><{$title}></title>
  7. </head>
  8. <body>
  9. <{$content}>
  10. </body>
  11. </html>
  1. // index.php 调用该模板
  2. // vim index.php
  3. <!DOCTYPE html>
  4. <html>
  5. <head>
  6. </head>
  7. <body>
  8. <?php
  9. require "main.php";
  10. $tpl->assign("title", "test");
  11. $tpl->assign("content", "test_1");
  12. // 上面两行也可以用这行代替
  13. // $tpl->assign(array("title" => "测试用的网页标题", "content" => "测试用的网页内容"));
  14. $tpl->display('test.htm'); // 调用模板
  15. ?>
  • 显示效果:

php 模板框架之smarty 的下载和安装的更多相关文章

  1. CSS 框架之 Bootstrap 的下载和安装

    BootStrap 简介: Bootstrap 是一个用于快速开发 Web 应用程序和网站的前端框架.Bootstrap 是基于 HTML.CSS.JAVASCRIPT 的. 响应式设计:Bootst ...

  2. Ci框架整合smarty模板引擎

    Ci框架整合smarty模板引擎 备注:下载smarty时,最好选择2.6版本,其他测试有坑,ci可以是2.2或其他 大体思路:将smarty封装成ci框架的一个类,然后重新配置一下smarty,这样 ...

  3. PHP做Web开发的MVC框架(Smarty使用说明 )

    PHP做Web开发的MVC框架(Smarty使用说明 ) 一.Smarty简明教程 1.安装演示 下载最新版本的Smarty-3.1.12,然后解压下载的文件.接下来演示Smarty自带的demo例子 ...

  4. ci框架与smarty的整合

    ci框架与smarty的整合 来源:未知    时间:2014-10-20 11:38   阅读数:108   作者:xbdadmin [导读] Ci 和 smarty 的完美结合 Ci 结合 sma ...

  5. ssh框架文件上传下载

    <!doctype html> <html lang="en"> <head> <meta charset="UTF-8&quo ...

  6. 一个超级简单的HTML模板框架源代码以及使用示例

    HTML模板框架源代码 var HtmlTemplate = (function () { function HtmlTemplate(htmlSource) { this.htmlSource = ...

  7. 1.Smarty的下载安装

    下载地址:https://github.com/smarty-php/smarty/tree/v3.1.29 官网:smarty.net 下载解压后的目录:

  8. 基于Webpack, KnockoutJs,esyui,koeasyui实现类vue-cli生成的模板框架

    前后端分离的开发机制,基本上是开发现代业务系统的标配.可在国内某些特殊领域还是存在大量的以JQuery走天涯的现象,但其中也不泛有追求技术者,如不才的鄙人.不才的本人曾以JQuery走天涯:后又接受了 ...

  9. 命名空间namespace、smarty使用(视图分离,MVC)、smarty模板语法、smarty缓存、MVC模式

    一.命名空间:namespace 命名空间 可以理解为逻辑上的使用,为了防止重名 namespace :关键字 加载:require_once();//加载一次 include_once() 申明命名 ...

随机推荐

  1. es6中的import,export浏览器已经支持

    直接上代码, 成功测验了es6的新特性 import , export语法. 服务器返回 js文件时,要加上content-type: applicaiton/javascript 这个字段. ind ...

  2. 转:Sublime Text 2 实用快捷键[Mac OS X]

    转: http://lucifr.com/2011/09/10/sublime-text-2-useful-shortcuts/ Sublime Text 2 实用快捷键[Mac OS X] luca ...

  3. HDU2089 ------不要62(数位dp)

    不要62 Time Limit: 1000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total Submi ...

  4. java基础知识精华

    转载:https://www.jianshu.com/p/6c078abb720f java基础知识 java内存模型 java运行时数据区域 hashMap 如何解决冲突 存储方式 冲突达到一定数量 ...

  5. canvas的api

    Canvas API(画布)用于在网页实时生成图像,并且可以操作图像内容,基本上它是一个可以用JavaScript操作的位图(bitmap).使用前,首先需要新建一个canvas网页元素. 1 2 3 ...

  6. Linux下统计当前文件夹下的文件个数、目录个数(转)

    1) 统计当前文件夹下文件的个数 代码如下: ls -l |grep "^-"|wc -l 2) 统计当前文件夹下目录的个数 代码如下: ls -l |grep "^d& ...

  7. 登陆Oracle EBS的Form遇到问题Internet Explorer has modified this page to help prevent cross-site scripting

    登陆Oracle EBS的Form遇到问题Internet Explorer has modified this page to help prevent cross-site scripting 今 ...

  8. unix 网络编程 第五章

    个人对unix 网络编程中的代码进行了精简,保留了主要和关键部分. 1 tcpserve01 程序见 https://github.com/juniperdiego/Unix-network-prog ...

  9. mindmanager2018优化

      mindmanager2018优化 CreationTime--2018年6月6日09:35:02 Author:Marydon 1.点击“文件”-“选项”进入配置界面,在“常规”选项中,建议勾选 ...

  10. [Done]com.aerospike.client.AerospikeException: Error Code 12: Bin type error

    今天遇到了一个问题:com.aerospike.client.AerospikeException: Error Code 12: Bin type error 异常栈: 网上找了一些资料:https ...