• Smarty 官网:

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

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

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

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. 【React】初识React

    React是什么 React是如今(2015年)最热门的前端技术. 在React中.一切皆组件. A JavaScript library for building user interfaces R ...

  2. log4j.properties 详解与配置步骤总结

    先提供一个项目中使用log4j.properties配置 #log4j.rootLogger=WARN, stdout, file log4j.rootLogger=INFO,console,dail ...

  3. 转自http://bbs.linuxtone.org/thread-1062-1-1.html

    详细参考:http://wiki.codemongers.com/NginxChsHttpMainModule worker_processes指明了nginx要开启的进程数,据官方说法,一般开一个就 ...

  4. 《iOS用户体验》总结与思考-改动版

    假设转载此文.请注明出处:http://blog.csdn.net/paulery2012/article/details/25157347,谢谢. 前言: 本文是在阅读<ios用户体验> ...

  5. ImageResizer for .net 图片处理强大类库

    http://imageresizing.net / 官网 http://imageresizing.net/docs/basics (文档) 变换尺寸,加边框,覆盖文本,和旋转和分割图象

  6. Python 转义符

    定义字符串前面我们讲解了什么是字符串.字符串可以用''或者""括起来表示.如果字符串本身包含'怎么办?比如我们要表示字符串 I'm OK ,这时,可以用" "括 ...

  7. excel 获取中文拼音首字母

      excel 获取中文拼音首字母 CreateTime--2018年5月31日08:50:42 Author:Marydon 1.情景展示 想要获取姓名的拼音首字母 2.实现方式 通过使用excel ...

  8. TypeError: can't convert console.log(...) to primitive type

    一.背景 火狐浏览器提示这个错误,谷歌没有. 二.出错代码 var eventHandlers = { 'succeeded': function(e){ console.log('send succ ...

  9. oracle 错误码查看命令oerr ora及常用错误码总结--不断更新

    oracle 错误码查看命令oerr ora及常用错误码总结--不断更新 1.ORA-00907: 缺失右括号 我自己的问题出在 字段的default 和 not null 顺序反了,defalut ...

  10. cordova添加Splash

    最新版本的cordova添加Splash只需要改写config.xml 官方文档地址为:http://cordova.apache.org/docs/en/4.0.0/config_ref_image ...