1 / 2
文档名称:

PHP之Smarty入门5.doc

格式:doc   大小:40KB   页数:2页
下载后只包含 1 个 DOC 格式的文档,没有任何的图纸或源代码,查看文件列表

如果您已付费下载过本站文档,您可以点这里二次下载

分享

预览

PHP之Smarty入门5.doc

上传人:rjmy2261 2018/6/22 文件大小:40 KB

下载得到文件列表

PHP之Smarty入门5.doc

相关文档

文档介绍

文档介绍:PHP之Smarty入门
最后我们整理一下整个 Smarty 程式撰写步骤:
Step 1. 加载 Smarty 模版引擎。
Step 2. 建立 Smarty 对象。
Step 3. 设定 Smarty 对象的参数。
Step 4. 在程式中处理变量后,再用 Smarty 的 assign 方法将变量置入模版里。
Step 5. 利用 Smarty 的 display 方法将网页秀出。
怎么安排你的程式架构
上面我们看到除了 Smarty 所需要的资料夹外(class 、 configs 、 templates 、 templates_c) ,更有两个资料夹: includes 、 modules 。其实这是笔者模仿 XOOPS 的架构所建立出来的,因为 XOOPS 是笔者所接触到的程式中,少数使用 Smarty 模版引擎的架站程式。所谓西瓜偎大边,笔者这样的程式架构虽没有 XOOPS 的百分之一强,但至少给人看时更有 XOOPS 撑腰。
includes 这个资料夹主要是用来放置一些 function 、 sql ?,这样在 就能将他们引入了,如下:
:
<?php
include "class/";
define(’__SITE_ROOT’, ’d:/appserv/web/demo’); // 最后没有斜线
// 以 的位置为基准
require_once "includes/";
require_once "includes/";
$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